-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Closure library and module system from the Blockly codebase? #6858
Labels
Comments
4 tasks
4 tasks
This was referenced Aug 11, 2023
This was referenced Aug 19, 2023
All remaining work has been split out into individual issues. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a discussion + tracking bug for work to remove our remaining dependencies on the Closure library (of which
closure/goog/base.js
and…/goog.js
are the only remaining pieces) and the Closure module system (goog.module
/goog.require
).The existence of this bug does not denote that a decision to remove the Closure library from our codebase; it exists merely to document what would be involved in doing so and track what work is done in that direction, as well as to provide a place to discuss the merits of such work.
Background
Terminology
There are several related but separate Google products named "Closure":
goog.module
.Overview, Motivation and Limitations
Use of the Closure module system ties us to
base.js
for uncompiled-mode loading and to Closure Compiler for bundling. Since we'd like to try alternative bundlers such as Webpack, it would be good to remove our remaining use of the module system.Even once we have fully removed use of the Closure module system we may wish to retain use of the debug module loader (in
base.js
) at least in the short term because it can do useful things like load JS scripts (via<script>
tags) after ES modules have beenimport
ed.We will probably wish to continue to use Closure Compiler at least until an alternative bunding/minification tool has been proven to be a good alternative. This is likely to entail our continued use of
closure-calculate-chunks
which depends onclosure-make-deps
which in turn expects the existence of at least a minimalbase.js
.Work already completed
(…as of the creation of this bug, late February 2023)
goog.module
etc.) incore/
was retired with PR chore: Migrate core/ to Typescript, actually #6299 (see also issue Update Blockly codebase to Typescript #5857), but we still use it in various places, notably inblocks/
andgenerators/
.import
cycles amongst modules incore/
.closure-make-deps
enforces a rule against circulargoog.require
s because the semantics of Closure modules do not allow these.import
ed first.closure-make-deps
does not enforce a rule againstimport
cycles, but the debug module loader (somewhat accidentally) does in some cases, due to assertion check in its simplistic implementation ofgoog.declareModuleId
.goog.module.get
for ESM modules, we introduced a number ofimport
cycles while convertingcore/
from Closure modules to TypeScript modules.import
incore/
#6818.Remaining Work
Convert remaining
goog.module
s to ES Modules (or TypeScript modules)We almost certainly want to do all of this, as these are blockers for trying Webpack.
blocks/*
andgenerators/*
: tracked (as part of the migration to TypeScript) in Convertblocks/
andgenerators/
to TypeScript #6828.core/main.js
: most of this is deprecatedget
/set
acccessors which can be deleted, but here may be some technical challenges converting any remaining code to TS or ESM because:core/
.tests/compile/test_blocks.js
tests/compile/main.js
Remove other remaining uses of
goog.require
These are relatively straight forward to do once we no longer have any
goog.module
s.import
:tests/mocha/index.html
tests/mocha/field_multilineinput_test.js
tests/mocha/generator_test.js
Deprecate
bootstrap.js
and the debug module loaderModifyReplacetests/bootstrap.js
and helpers to useimport
instead ofgoog.require
. This may involve a substantial rewrite, if we cannot continue to usegoog.bootstrap
.tests/bootstrap.js
:import
the chunk entry point or use a<script>
tag to load the compressed chunk, and then (in either case)export
the chunk's public API.tests/playground.html
to use shims.tests/multi_playground.html
to use shims.tests/playgrounds/advanced_playground.html
to use shims.tests/mocha/index.html
to use shims.tests/generators/index.html
to use shims.tests/bootstrap.js
et al.Remove Closure library
This is lower-priority work, but would let us remove a bunch of cruft from our codebase and build pipeline.
goog.declareModuleId()
throughout the codebase.goog.require
calls, these are no longer needed.goog.module
IDs #7471base.js
.closure-make-deps
as well as the Closure Compiler.base_minimal.js
if we continue to use those tools, as they mostly operate on paths relative tobase.js
.closure-make-deps
andclosure-calculate-chunks
#7469closure/goog/base.js
.closure/goog/goog.js
.closure/*
.Cleanup
sortRequires
gulp task #7470The text was updated successfully, but these errors were encountered: