Skip to content

Commit

Permalink
refactor: Remove $build$src infix from munged paths
Browse files Browse the repository at this point in the history
Closure Compiler renames module globals so that they do not
clash when multiple modules are bundled together.  It does so
by adding a "$$module$build$src$path$to$module" suffix (with
the module object istelf being named simply
"$module$build$src$path$to$module").

By changing the gulp.src base option to be build/src/ instead
of ./ (referring to the repostiory root), Closure Compiler
obligingly shortens all of these munged named by removing the
"$build$src" infix, reducing the size of the compressed chunks
by about 10%; blockly_compressed.js goes from 900595 to 816667
bytes.
  • Loading branch information
cpcallen committed Sep 8, 2023
1 parent 39baf01 commit 06d78af
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions scripts/gulpfiles/build_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,53 +106,53 @@ const chunks = [
files: 'core/**/*.js',
entry: path.join(TSC_OUTPUT_DIR, 'core', 'main.js'),
moduleEntry: path.join(TSC_OUTPUT_DIR, 'core', 'blockly.js'),
exports: 'module$build$src$core$blockly',
exports: 'module$core$blockly',
scriptExport: 'Blockly',
},
{
name: 'blocks',
files: 'blocks/**/*.js',
entry: path.join(TSC_OUTPUT_DIR, 'blocks', 'blocks.js'),
exports: 'module$build$src$blocks$blocks',
exports: 'module$blocks$blocks',
scriptExport: 'Blockly.libraryBlocks',
},
{
name: 'javascript',
files: ['generators/javascript.js', 'generators/javascript/**/*.js'],
entry: path.join(TSC_OUTPUT_DIR, 'generators', 'javascript.js'),
exports: 'module$build$src$generators$javascript',
exports: 'module$generators$javascript',
scriptExport: 'javascript',
scriptNamedExports: {'Blockly.JavaScript': 'javascriptGenerator'},
},
{
name: 'python',
files: ['generators/python.js', 'generators/python/**/*.js'],
entry: path.join(TSC_OUTPUT_DIR, 'generators', 'python.js'),
exports: 'module$build$src$generators$python',
exports: 'module$generators$python',
scriptExport: 'python',
scriptNamedExports: {'Blockly.Python': 'pythonGenerator'},
},
{
name: 'php',
files: ['generators/php.js', 'generators/php/**/*.js'],
entry: path.join(TSC_OUTPUT_DIR, 'generators', 'php.js'),
exports: 'module$build$src$generators$php',
exports: 'module$generators$php',
scriptExport: 'php',
scriptNamedExports: {'Blockly.PHP': 'phpGenerator'},
},
{
name: 'lua',
files: ['generators/lua.js', 'generators/lua/**/*.js'],
entry: path.join(TSC_OUTPUT_DIR, 'generators', 'lua.js'),
exports: 'module$build$src$generators$lua',
exports: 'module$generators$lua',
scriptExport: 'lua',
scriptNamedExports: {'Blockly.Lua': 'luaGenerator'},
},
{
name: 'dart',
files: ['generators/dart.js', 'generators/dart/**/*.js'],
entry: path.join(TSC_OUTPUT_DIR, 'generators', 'dart.js'),
exports: 'module$build$src$generators$dart',
exports: 'module$generators$dart',
scriptExport: 'dart',
scriptNamedExports: {'Blockly.Dart': 'dartGenerator'},
},
Expand Down Expand Up @@ -552,7 +552,7 @@ function buildCompiled() {
};

// Fire up compilation pipline.
return gulp.src(chunkOptions.js, {base: './'})
return gulp.src(chunkOptions.js, {base: TSC_OUTPUT_DIR})
.pipe(stripApacheLicense())
.pipe(gulp.sourcemaps.init())
.pipe(compile(options))
Expand Down

0 comments on commit 06d78af

Please sign in to comment.