diff --git a/.eslintignore b/.eslintignore index 4793ef969..c884c6b9e 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,6 +1,5 @@ *_compressed*.js *_uncompressed*.js -blockly_node_javascript_en.js gulpfile.js /msg/* /core/utils/global.js diff --git a/.gitignore b/.gitignore index 57e06ee5e..87aa424ce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -blockly_node_javascript_en.js node_modules npm-debug.log build-debug.log diff --git a/gulpfile.js b/gulpfile.js index 41732bb02..a69c353d9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -337,80 +337,6 @@ gulp.task('build', gulp.parallel( 'build-dart' )); -//////////////////////////////////////////////////////////// -// Node // -//////////////////////////////////////////////////////////// - -// Concatenates the necessary files to load Blockly in a Node.js VM. Blockly's -// individual libraries target use in a browser, where globals (via the window -// objects) are used to share state and APIs. By concatenating all the -// necessary components into a single file, Blockly can be loaded as a Node.js -// module. -// -// This task builds Node with the assumption that the app needs English blocks -// and JavaScript code generation. If you need another localization or -// generator language, just copy and edit the srcs. Only one localization -// language can be included. -gulp.task('blockly_node_javascript_en', function() { - var srcs = [ - 'blockly_compressed.js', - 'blocks_compressed.js', - 'javascript_compressed.js', - 'msg/js/en.js' - ]; - // Concatenate the sources, appending the module export at the bottom. - // Override textToDomDocument, providing Node alternative to DOMParser. - return gulp.src(srcs) - .pipe(gulp.concat('blockly_node_javascript_en.js')) - .pipe(gulp.insert.append(` -if (typeof DOMParser !== 'function') { - var JSDOM = require('jsdom').JSDOM; - var window = (new JSDOM()).window; - var document = window.document; - var Element = window.Element; - Blockly.utils.xml.textToDomDocument = function(text) { - var jsdom = new JSDOM(text, { contentType: 'text/xml' }); - return jsdom.window.document; - }; -} -if (typeof module === 'object') { module.exports = Blockly; } -if (typeof window === 'object') { window.Blockly = Blockly; }\n`)) - .pipe(gulp.dest('.')); -}); - -/** - * Task-builder for the watch function. Currently any change invokes the whole - * build script. Invoke with "gulp watch". - * - * @param {?string=} concatTask Name of the concatenating task for node usage. - */ -// TODO: Only run the necessary phases of the build script for a given change. -function buildWatchTaskFn(concatTask) { - return function() { - // Tasks to trigger. - var tasks = ['build']; - if (concatTask) { - tasks.push(concatTask); - } - - // Currently any changes invokes the whole build script. (To fix.) - var srcs = [ - 'core/**/*.js', // Blockly core code - 'blocks/*.js', // Block definitions - 'generators/**/*.js', // Code generation - 'msg/messages.js', 'msg/json/*.json' // Localization data - ]; - var options = { - debounceDelay: 2000 // Milliseconds to delay rebuild. - }; - gulp.watch(srcs, options, gulp.parallel(tasks)); - }; -} - -// Watch Blockly files for changes and trigger automatic rebuilds, including -// the Node-ready blockly_node_javascript_en.js file. -gulp.task('watch', buildWatchTaskFn('blockly_node_javascript_en')); - //////////////////////////////////////////////////////////// // Typings // //////////////////////////////////////////////////////////// @@ -863,6 +789,5 @@ gulp.task('release', gulp.series(['build', 'typings', function() { fs.mkdirSync(packageDistribution); }, 'package'])); -// The default task concatenates files for Node.js, using English language -// blocks and the JavaScript generator. -gulp.task('default', gulp.series(['build', 'blockly_node_javascript_en'])); +// The default task builds Blockly. +gulp.task('default', gulp.series(['build'])); diff --git a/package.json b/package.json index 615beaacc..20f3e4789 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "build:debug": "gulp build-core --verbose > build-debug.log 2>&1", "lint": "eslint .", "package": "gulp package", - "prepare": "gulp blockly_node_javascript_en", + "prepare": "npm run package", "release": "gulp release", "test": "concurrently 'npm run test:prepare' 'sleep 5 && npm run test:run'", "test:run": "tests/run_all_tests.sh", diff --git a/tests/node/run_node_test.js b/tests/node/run_node_test.js index d934f8355..cc76ebfab 100644 --- a/tests/node/run_node_test.js +++ b/tests/node/run_node_test.js @@ -23,7 +23,7 @@ */ var assert = require('chai').assert; -var Blockly = require('../../blockly_node_javascript_en.js'); +var Blockly = require('../../dist/'); var xmlText = `