diff --git a/core/main.js b/core/main.js index 9606a67b6..99d8f7da0 100644 --- a/core/main.js +++ b/core/main.js @@ -7,7 +7,7 @@ /** * @fileoverview The entrypoint for blockly_compressed.js. Provides * various backwards-compatibility hacks. Not used when loading - * in uncompiled (uncompressed) mode via bootstrap.js. + * in uncompiled (uncompressed) mode via blockly.loader.mjs. */ 'use strict'; diff --git a/package.json b/package.json index 6c3c886f1..f01be3205 100644 --- a/package.json +++ b/package.json @@ -24,14 +24,12 @@ "build-strict-log": "npm run build:strict > build-debug.log 2>&1 && tail -3 build-debug.log", "build:compiled": "exit 1 # Deprecated; use \"npm run minify\" instead.", "build:compressed": "exit 1 # Deprecated; use \"npm run minify\" instead.", - "build:deps": "exit 1 # Deprecated; use \"npm run deps\" instead.", "build:js": "exit 1 # Deprecated; use \"npm run tsc\" instead.", "build:langfiles": "exit 1 # Deprecated; use \"npm run langfiles\" instead.", "bump": "npm --no-git-tag-version version 4.$(date +'%Y%m%d').0", "clean": "gulp clean", "deployDemos": "npm ci && gulp deployDemos", "deployDemos:beta": "npm ci && gulp deployDemosBeta", - "deps": "gulp deps", "docs": "gulp docs", "format": "prettier --write .", "format:check": "prettier --check .", diff --git a/scripts/gulpfiles/build_tasks.js b/scripts/gulpfiles/build_tasks.js index 0d7517750..75b0ebcf7 100644 --- a/scripts/gulpfiles/build_tasks.js +++ b/scripts/gulpfiles/build_tasks.js @@ -22,7 +22,7 @@ const closureCompiler = require('google-closure-compiler').gulp(); const argv = require('yargs').argv; const {rimraf} = require('rimraf'); -const {BUILD_DIR, DEPS_FILE, RELEASE_DIR, TSC_OUTPUT_DIR, TYPINGS_BUILD_DIR} = require('./config'); +const {BUILD_DIR, RELEASE_DIR, TSC_OUTPUT_DIR, TYPINGS_BUILD_DIR} = require('./config'); const {getPackageJson} = require('./helper_tasks'); const {posixPath, quote} = require('../helpers'); @@ -43,6 +43,11 @@ const PYTHON = process.platform === 'win32' ? 'python' : 'python3'; */ const COMPILED_SUFFIX = '_compressed'; +/** + * Dependencies file (used by buildCompiled for chunking. + */ +const DEPS_FILE = path.join(BUILD_DIR, 'deps.js'); + /** * Name of an object to be used as a shared "global" namespace by * chunks generated by the Closure Compiler with the @@ -302,8 +307,9 @@ function buildJavaScript(done) { } /** - * This task updates DEPS_FILE (deps.js), used by the debug module - * loader (via bootstrap.js) when loading Blockly in uncompiled mode. + * This task updates DEPS_FILE (deps.js), used by + * closure-calculate-chunks when determining how to organise .js + * source files into chunks. * * Prerequisite: buildJavaScript. */ @@ -354,7 +360,6 @@ error message above, try running: reject(error); } else { log(stderr); - // Anything not about mocha goes in DEPS_FILE. fs.writeFileSync(DEPS_FILE, stdout); resolve(); } @@ -710,7 +715,7 @@ ${Object.keys(exports).map((name) => ` ${name},`).join('\n')} * This task builds Blockly core, blocks and generators together and uses * Closure Compiler's ADVANCED_COMPILATION mode. * - * Prerequisite: buildDeps. + * Prerequisite: buildJavaScript. */ function buildAdvancedCompilationTest() { // If main_compressed.js exists (from a previous run) delete it so that @@ -761,14 +766,13 @@ function cleanBuildDir() { exports.cleanBuildDir = cleanBuildDir; exports.langfiles = buildLangfiles; // Build build/msg/*.js from msg/json/*. exports.tsc = buildJavaScript; -exports.deps = gulp.series(exports.tsc, buildDeps); -exports.minify = gulp.series(exports.deps, buildCompiled, buildShims); +exports.minify = gulp.series(exports.tsc, buildDeps, buildCompiled, buildShims); exports.build = gulp.parallel(exports.minify, exports.langfiles); // Manually-invokable targets, with prerequisites where required. exports.messages = generateMessages; // Generate msg/json/en.json et al. exports.buildAdvancedCompilationTest = - gulp.series(exports.deps, buildAdvancedCompilationTest); + gulp.series(exports.tsc, buildAdvancedCompilationTest); // Targets intended only for invocation by scripts; may omit prerequisites. exports.onlyBuildAdvancedCompilationTest = buildAdvancedCompilationTest; diff --git a/scripts/gulpfiles/config.js b/scripts/gulpfiles/config.js index 02a0499c4..e1756d96e 100644 --- a/scripts/gulpfiles/config.js +++ b/scripts/gulpfiles/config.js @@ -19,15 +19,10 @@ const path = require('path'); // - tests/scripts/compile_typings.sh // - tests/scripts/check_metadata.sh // - tests/scripts/update_metadata.sh -// - tests/bootstrap.js (for location of deps.js) -// - tests/mocha/index.html (for location of deps.mocha.js) // Directory to write compiled output to. exports.BUILD_DIR = 'build'; -// Dependencies file (used by bootstrap.js in uncompiled mode): -exports.DEPS_FILE = path.join(exports.BUILD_DIR, 'deps.js'); - // Directory to write typings output to. exports.TYPINGS_BUILD_DIR = path.join(exports.BUILD_DIR, 'declarations'); diff --git a/scripts/migration/js2ts b/scripts/migration/js2ts index 4ddfd18ba..a8d941e01 100755 --- a/scripts/migration/js2ts +++ b/scripts/migration/js2ts @@ -54,7 +54,6 @@ goog.addDependency = function(relPath, provides, _requires, opt_loadFlags) { // Load deps files relative to this script's location. require(path.resolve(__dirname, '../../build/deps.js')); -require(path.resolve(__dirname, '../../build/deps.mocha.js')); ////////////////////////////////////////////////////////////////////// // Process files mentioned on the command line. diff --git a/tests/bootstrap.js b/tests/bootstrap.js deleted file mode 100644 index dace6e3a1..000000000 --- a/tests/bootstrap.js +++ /dev/null @@ -1,276 +0,0 @@ -/** - * @license - * Copyright 2021 Google LLC - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * @fileoverview Bootstrap code to load Blockly, typically in - * uncompressed mode. - * - * Load this file in a `, - ); - - // Prevent spurious transpilation warnings. - document.write(''); - - // Load dependency graph info from the specified deps files - - // typically just build/deps.js. To update deps after changing - // any module's goog.requires / imports, run `npm run build:deps`. - for (const depsFile of options.depsFiles) { - document.write(``); - } - - // Assemble a list of module targets to bootstrap. - // - // The first group of targets are those listed in options.modules - // and options.requires. These are recorded on bootstrapInfo so - // so bootstrap_helper.js can goog.require() them to force loading - // to complete. - // - // The next target is a fake one that will load - // bootstrap_helper.js. We generate a call to goog.addDependency - // to tell the debug module loader that it can be loaded via a - // fake module name, and that it depends on all the targets in the - // first group (and indeed bootstrap_helper.js will make a call to - // goog.require for each one). - // - // We then create another target for each of options.scripts, - // again generating calls to goog.addDependency for each one - // making it dependent on the previous one. - let requires = (window.bootstrapInfo.requires = [ - ...options.modules.map((module) => module.id), - ...options.requires, - ]); - - const scripts = ['tests/bootstrap_helper.js', ...options.scripts]; - const scriptDeps = []; - for (const script of scripts) { - const fakeModuleName = `script.${script.replace(/[./]/g, '-')}`; - scriptDeps.push( - `goog.addDependency(${quote('../../../../' + script)}, ` + - `[${quote(fakeModuleName)}], [${requires.map(quote).join()}], ` + - `{'lang': 'es6'});`, - ); - requires = [fakeModuleName]; - } - - // Finally, write out a script containing the generated - // goog.addDependency calls and a call to goog.bootstrap - // requesting the loading of the final target, which will cause - // all the previous ones to be loaded recursively. Wrap this in a - // promise and save it so it can be awaited in bootstrap_done.mjs. - document.write(``); - } else { - // We need to load Blockly in compressed mode. Load - // blockly_compressed.js et al. using `); - } - } - - return; // All done. Only helper functions after this point. - - /** - * Convert a string into a string literal. Strictly speaking we - * only need to escape backslash, \r, \n, \u2028 (line separator), - * \u2029 (paragraph separator) and whichever quote character we're - * using, but for simplicity we escape all the control characters. - * - * Based on https://github.com/google/CodeCity/blob/master/server/code.js - * - * @param {string} str The string to convert. - * @return {string} The value s as a eval-able string literal. - */ - function quote(str) { - /* eslint-disable no-control-regex, no-multi-spaces */ - /** Regexp for characters to be escaped in a single-quoted string. */ - const singleRE = /[\x00-\x1f\\\u2028\u2029']/g; - - /** Map of control character replacements. */ - const replacements = { - '\x00': '\\0', - '\x01': '\\x01', - '\x02': '\\x02', - '\x03': '\\x03', - '\x04': '\\x04', - '\x05': '\\x05', - '\x06': '\\x06', - '\x07': '\\x07', - '\x08': '\\b', - '\x09': '\\t', - '\x0a': '\\n', - '\x0b': '\\v', - '\x0c': '\\f', - '\x0d': '\\r', - '\x0e': '\\x0e', - '\x0f': '\\x0f', - '"': '\\"', - "'": "\\'", - '\\': '\\\\', - '\u2028': '\\u2028', - '\u2029': '\\u2029', - }; - /* eslint-enable no-control-regex, no-multi-spaces */ - - return "'" + str.replace(singleRE, (c) => replacements[c]) + "'"; - } -})(); diff --git a/tests/bootstrap_done.mjs b/tests/bootstrap_done.mjs deleted file mode 100644 index 86ebcb4ad..000000000 --- a/tests/bootstrap_done.mjs +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * @fileoverview Finishes loading Blockly and exports it as this - * module's default export. - * - * It is exported as the default export to avoid having to - * re-export each property on Blockly individually, because you - * can't do: - * - * export * from ; // SYNTAX ERROR - * - * You must use a - - + diff --git a/tests/generators/webdriver.js b/tests/generators/webdriver.js index a422323ec..71170f6ef 100644 --- a/tests/generators/webdriver.js +++ b/tests/generators/webdriver.js @@ -73,6 +73,10 @@ async function runGeneratorsInBrowser(outputDir) { console.log('Loading url: ' + url); await browser.url(url); + await browser + .$('.blocklySvg .blocklyWorkspace > .blocklyBlockCanvas') + .waitForExist({timeout: 2000}); + await browser.execute(function() { checkAll(); loadSelected(); diff --git a/tests/mocha/index.html b/tests/mocha/index.html index f94eabfa1..160c74b0b 100644 --- a/tests/mocha/index.html +++ b/tests/mocha/index.html @@ -18,9 +18,9 @@
- +