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(tests): Fix bootstrapping of generators in compressed mode #6703

Merged
merged 1 commit into from
Dec 14, 2022

Conversation

cpcallen
Copy link
Contributor

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

Broken generators in (basic) playground.

Proposed Changes

Previously we had code that would, in uncompiled mode, make sure that javascriptGenerator etc. were set to the corresponding module exports object (by fetching it with goog.module.get), but in compressed mode we made no effort to set (e.g.) javascriptGenerator to Blockly.JavaScript, which is where that export actually appears in the namespace tree when loading the chunk via a <script> tag.

This commit introduces two new configuration options to bootstrap.js (preconfigured with defaults that should work in most cases) mapping global variable names to their corresponding module identifiers, and modifies the code in bootstrap_helper.js to set global variables appropriately in both uncompressed and compressed modes.

Behaviour Before Change

javascriptGenerator et al. are only set in uncompressed mode.

Behaviour After Change

javascriptGenerator et al. are only set in both uncomrpessed and compressed mode.

Additional Information

This was supposed to be a fix for #6597, but in fact the problems with advanced playground are more thorny, because (as used in tests/playgrounds/advanced.html) it actually ends up using two separate copies of Blockly simultaneously.

Previously we had code that would, in uncompiled mode, make sure
that javascriptGenerator etc. were set to the corresponding module
exports object (by fetching it with goog.module.get), but in
compressed mode we made no effort to set (e.g.) javascriptGenerator
to Blockly.JavaScript, which is where that export actually appears
in the namespace tree when loading the chunk via a <script> tag.

This commit introduces two new configuration options to bootstrap.js
(preconfigured with defaults that should work in most cases) mapping
global variable names to their corresponding module identifiers, and
modifies the code in bootstrap_helper.js to set global variables
appropriately in both uncompressed and compressed modes.
@cpcallen cpcallen requested a review from a team as a code owner December 14, 2022 18:00
@cpcallen cpcallen requested a review from BeksOmega December 14, 2022 18:00
@github-actions github-actions bot removed the PR: fix Fixes a bug label Dec 14, 2022
@github-actions github-actions bot added the PR: fix Fixes a bug label Dec 14, 2022
@cpcallen cpcallen merged commit f528ecc into google:develop Dec 14, 2022
@cpcallen cpcallen deleted the fix-playground-generators branch December 14, 2022 19:47
maribethb added a commit to maribethb/blockly that referenced this pull request Jan 12, 2023
maribethb added a commit to maribethb/blockly that referenced this pull request Jan 13, 2023
cpcallen added a commit to cpcallen/blockly that referenced this pull request Feb 8, 2023
Prior to PR google#6818, circular imports resulted in the debug module
loader (in closure/goog/base.js) failing to record the
goog.module ID of most modules that were
involved in the cycle, and in particular of the Blockly.Xml
module.  This had secondary fallout that resulted
in library blocks modules being loaded in the wrong order.

A kludge was introduced in PR google#6703 that worked around this
problem by making sure that window.Blockly was set, allowing
the modules loaded out-of-order to still work.

Now that we have removed all remaining circular dependencies
there is no need for the kludge, since all module IDs are
properly recorded and modules are loaded in the correct order.
cpcallen added a commit that referenced this pull request Feb 8, 2023
* chore(tests): Remove circular import loading issue kludge

  Prior to PR #6818, circular imports resulted in the debug module
  loader (in closure/goog/base.js) failing to record the
  goog.module ID of most modules that were
  involved in the cycle, and in particular of the Blockly.Xml
  module.  This had secondary fallout that resulted
  in library blocks modules being loaded in the wrong order.

  A kludge was introduced in PR #6703 that worked around this
  problem by making sure that window.Blockly was set, allowing
  the modules loaded out-of-order to still work.

  Now that we have removed all remaining circular dependencies
  there is no need for the kludge, since all module IDs are
  properly recorded and modules are loaded in the correct order.

* chore(build): Remove exclude for non-existent core/blockly.js

  There was a transitional period where we had both
  core/blockly.ts and core/blockly.js, and wished to exclude
  the latter from tsc's input, but the latter file was deleted
  (and inadvertently restored, then re-deleted) some time ago.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants