Files
blockly/tests/blockly.mjs
Christopher Allen dc16094551 refactor(tests): Move and rename prepare.js, blockly.mjs
Since prepare.js and blockly.mjs are going to be needed for running
all tests in uncompiled mode (not just the playgrounds), move them
tests/.  Further, rename prepare.js to bootstrap.js to better reflect
its purpose.
2022-06-14 23:33:39 +01:00

40 lines
1.1 KiB
JavaScript

/**
* @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 <dynamically computed source>; // SYNTAX ERROR
*
* You must use a <script> tag to load prepare.js first, before
* importing this module in a <script type=module> to obtain the
* loaded value.
*
* See tests/playground.html for example usage.
*/
let Blockly;
if (window.BlocklyLoader) {
// Uncompiled mode. Use top-level await
// (https://v8.dev/features/top-level-await) to block loading of
// this module until goog.bootstrap()ping of Blockly is finished.
await window.BlocklyLoader;
Blockly = globalThis.Blockly;
} else if (window.Blockly) {
// Compiled mode. Retrieve the pre-installed Blockly global.
Blockly = globalThis.Blockly;
} else {
throw new Error('neither window.Blockly nor window.BlocklyLoader found');
}
export default Blockly;