mirror of
https://github.com/google/blockly.git
synced 2026-01-28 19:20:10 +01:00
An earlier commit modified the generated <script> to use
goog.addDependency to trick the debug module loader into loading
.additionalScripts (via goog.bootstrap), but it turns out there is
a small problem: scripts like msg/messages.js have undeclared
dependencies on the Blockly module, and without a call to
goog.require('Blockly') in them they can end up being run before
the Blockly module is fully loaded.
(This problem only occurs when there are ES Modules, rather than
merely goog.modules, in the mix.)
Fix this by adding a script, bootstrap_helper.js, to be loaded
options.requires and any options.additionalScripts that makes an
explicit call to goog.require for each of option.requires.
Also refactor the code so that instead of generating a loop which
calls goog.addDependency, we generate the addDependency calls
directly. This makes debugging a bit easer as we can use the browser's
dev tools to inspect the generated calls in the DOM tree.
21 lines
568 B
JavaScript
21 lines
568 B
JavaScript
/**
|
|
* @license
|
|
* Copyright 2022 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* @fileoverview Helper script for bootstrap.js
|
|
*
|
|
* This is loaded, via goog.bootstrap(), after the other top-level
|
|
* Blockly modules. It simply calls goog.require() for each of them,
|
|
* to force the deubg module loader to finish loading them before any
|
|
* non-module scripts (like msg/messages.js) that might have
|
|
* undeclared dependencies on them.
|
|
*/
|
|
|
|
/* eslint-disable-next-line no-undef */
|
|
for (const require of BlocklyLoader.requires) {
|
|
goog.require(require);
|
|
}
|