Skip to content

Commit

Permalink
refactor: Update uncompiled-mode dependency loading for playground, t…
Browse files Browse the repository at this point in the history
…ests (#5715)

* chore: rename module Blockly.blocks.Lists to ....lists

All the other Blockly.blocks modules have lower-case names.  This
one being named with an upper-case initial appears to have been a
typo on my part.

This module name is not mentioned anywhere else in the source code
(though it will be soon!) so no other files need to be edited.
Further, it does not appear anywhere in the last release (which
before PR #5696) so it is not necessary to add an entry in
renamings.js for this change.

* chore(build): Rationalise deps.js, deps.mocha.js

* Include blocks/*.js (Blockly.blocks.*) in tests/deps.js, since
  these modules are used in the playground.  (They are goog.provide
  modules loaded via <script> tags, so their absence from deps.js
  does not cause errors - but it will when they are migrated to
  goog.module and must be loaded via goog.require.)

* Filter the entries in deps.mocha.js so that it includes only the
  additional mocha test modules (i.e. those not mentioned in deps.js
  already).

* refactor: Load blocks and generators using goog.require
  • Loading branch information
cpcallen authored Nov 17, 2021
1 parent 075385c commit 335ff19
Show file tree
Hide file tree
Showing 7 changed files with 202 additions and 462 deletions.
2 changes: 1 addition & 1 deletion blocks/lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
'use strict';

goog.provide('Blockly.blocks.Lists');
goog.provide('Blockly.blocks.lists');
goog.provide('Blockly.Constants.Lists');

goog.require('Blockly');
Expand Down
9 changes: 6 additions & 3 deletions scripts/gulpfiles/build_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ const buildGenerators = gulp.parallel(
/**
* This task updates tests/deps.js, used by blockly_uncompressed.js
* when loading Blockly in uncompiled mode.
*
* Also updates tests/deps.mocha.js, used by the mocha test suite.
*/
function buildDeps(done) {
const closurePath = argv.closureLibrary ?
Expand All @@ -342,20 +344,21 @@ function buildDeps(done) {
closurePath,
'core',
'blocks',
'generators',
];

const testRoots = [
...roots,
'generators',
'tests/mocha'
];

const args = roots.map(root => `--root '${root}' `).join('');
execSync(`closure-make-deps ${args} > tests/deps.js`, {stdio: 'inherit'});

// Use grep to filter out the entries that are already in deps.js.
const testArgs = testRoots.map(root => `--root '${root}' `).join('');
execSync(`closure-make-deps ${testArgs} > tests/deps.mocha.js`,
{stdio: 'inherit'});
execSync(`closure-make-deps ${testArgs} | grep 'tests/mocha'` +
' > tests/deps.mocha.js', {stdio: 'inherit'});
done();
};

Expand Down
52 changes: 51 additions & 1 deletion tests/deps.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 335ff19

Please sign in to comment.