fix!: Move backwards-compatibility hacks to main.js
#6260
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The basics
npm run format
andnpm run lint
The details
Resolves
Prerequisite to #5904 and #5857.
Proposed Changes
goog.module
,core/main.js
, which becomes the entry point for the first chunk in compiled mode. (It is not used in uncompiled mode.) Move to this new module:blockly.js
:globalThis.Blockly.Msg
via<script>
tagblockly.js
,contextmenu.js
,events/events.js
,tooltip.js
, andwidgetdiv.js
:Object.defineProperties
calls that provide backward-compatibilityget
/set
accessors for mutable exports that were removed in the migration togoog.module
.Blockly
namespace object in uncompiled mode.generator.js
. Since these are attached to theGenerator
class, which is a named export, instead of the the moduleexports
object, they do not need to be moved out of hat module—but they did have a five-year deprecation period, which has been shortened to end with the 2022Q3 release to bring it in line with the period for the other accessors.Reason for Changes
It is not possible to use
Object.defineProperties
to add properties to aModule
object, so this code can't be run in uncompiled mode. It works in compiled mode only because Closure Compiler is set to output ES5, and the generated code does not contain anyObject.seal
calls for (what would be) Module objects.Test Coverage
npm test
.Documentation
Release notes will need to contain information about what to use instead of the the accessor properties, especially for
.mainWorkspace
,.selected
,HSV_SATURATION
andHSV_VALUE
, which were not previously marked as deprecated.Additional Information
Obsoletes PR #6203.
Does not add deprecation notices to the previously non-deprecated
Blockly..mainWorkspace
,.selected
,.HSV_SATURATION
and.HSV_VALUE
accessors. We want to do that before the delayed Q2 release but it is not a prerequisite to this move, which is a prerequisite to mergingts/migration
intodevelop
.