From b1f0a6a867bf84446a424bbed20be4429604d545 Mon Sep 17 00:00:00 2001 From: Christopher Allen Date: Wed, 23 Feb 2022 10:30:21 +0000 Subject: [PATCH] refactor(tests): Use `goog.bootstrap` to allow loading ES modules in playground (#5931) * chore(deps): Update closure/goog/base.js, add goog.js * Update base.js from the latest version (20220104.0.0). * Also copy over goog.js, which provides access to asuitable subset of goog.* via an importable module). * refactor(tests): Have playground.html load Blockly as a module N.B.: * We still need a preparation step, in order to load base.js and deps.js via - + - +
diff --git a/tests/playgrounds/blockly.mjs b/tests/playgrounds/blockly.mjs new file mode 100644 index 000000000..dcbc95a6d --- /dev/null +++ b/tests/playgrounds/blockly.mjs @@ -0,0 +1,38 @@ +/** + * @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 '); + // Load dependency graph info from test/deps.js. To update + // deps.js, run `npm run build:deps`. + document.write(''); + + // Msg loading kludge. This should go away once #5409 and/or + // #1895 are fixed. + + // Load messages into a temporary Blockly.Msg object, deleting it + // afterwards (after saving the messages!) + window.Blockly = {Msg: Object.create(null)}; + document.write(''); + document.write(` + `); + + document.write(` + `); + } else { + // We need to load Blockly in compiled mode. + + // Load blockly_compressed.js et al. using '); + document.write(''); + document.write(''); + document.write(''); + document.write(''); + document.write(''); + document.write(''); + document.write(''); + } +})();