Skip to content
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

fix!: Move backwards-compatibility hacks to main.js #6260

Merged
merged 5 commits into from
Jul 5, 2022

Conversation

cpcallen
Copy link
Contributor

@cpcallen cpcallen commented Jul 5, 2022

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide
  • I ran npm run format and npm run lint

The details

Resolves

Prerequisite to #5904 and #5857.

Proposed Changes

  • Create a new 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:
    • from blockly.js:
      • the hack to allow setting globalThis.Blockly.Msg via <script> tag
    • from blockly.js, contextmenu.js, events/events.js, tooltip.js, and widgetdiv.js:
      • the Object.defineProperties calls that provide backward-compatibility get/set accessors for mutable exports that were removed in the migration to goog.module.
  • Delete the "temporary hack" that was needed to make the accessors available on the Blockly namespace object in uncompiled mode.
  • Update the end date of the deprecation period for similar accessor properties in generator.js. Since these are attached to the Generator class, which is a named export, instead of the the module exports 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 a Module 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 any Object.seal calls for (what would be) Module objects.

Test Coverage

  • Passes npm test.
  • Playground appears to work.

Documentation

Release notes will need to contain information about what to use instead of the the accessor properties, especially for .mainWorkspace, .selected, HSV_SATURATION and HSV_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 merging ts/migration into develop.

Move accessor properties for Blockly.alert, .confirm,
.mainWorkspace, .prompt, .selected, .HSV_SATURATION and
.HSV_VALUE, as well as the hack to allow loading of messages
via <script> tags, from core/blockly.js to core/main.js,
which becomes the entrypoint for the first chunk when
compiled.

BREAKING CHANGE: The aforementioned properties / hack are no
longer available in uncompiled mode (or when using advanced
compilation, unless also compiling against main.js.)
Move accessor property for ContextMenu.currentBlock from
core/contextmenu.js to core/main.js.
Bring the deprecation date forward from May 2026 to September 2022.

Not technically a breaking change—just a warning that there will
be a breaking change earlier than previously advertised.
Move accessor properties for Blockly.Tooltip.visible and .DIV
from core/tooltip.js to core/main.js.
Move accessor property for Blockly.WidgetDiv.DIV
from core/widgetdiv.js to core/main.js.
@cpcallen cpcallen added component: build process breaking change Used to mark a PR or issue that changes our public APIs. PR: chore General chores (dependencies, typos, etc) labels Jul 5, 2022
@cpcallen cpcallen requested a review from NeilFraser July 5, 2022 12:22
@cpcallen cpcallen requested a review from a team as a code owner July 5, 2022 12:22
@cpcallen cpcallen merged commit aaafbc2 into google:develop Jul 5, 2022
@cpcallen cpcallen deleted the blocklyjs-cleanup branch July 5, 2022 15:27
*/
confirm: {
set: function(newConfirm) {
deprecation.warn('Blockly.confirm', 'December 2021', 'December 2022');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we add deprecation warnings to mainWorkspace and friends, I think we should change this to be 'September 2022'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Used to mark a PR or issue that changes our public APIs. component: build process PR: chore General chores (dependencies, typos, etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants