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: Fix incorrect Blockly imports #2339

Merged
merged 1 commit into from
May 9, 2024
Merged

Conversation

cpcallen
Copy link
Contributor

@cpcallen cpcallen commented May 2, 2024

The basics

The details

Proposed Changes

We have for some time promulgated

import * as Blockly from 'blockly/core';

as the correct way to import Blockly in our documentation. Update our own plugins and templates to match.

Reason for Changes

Because we have been packaging Blockly until now only as CJS modules, and CJS modules always provide an (unnamed) default export consisting of the module.exports object, importing Blockly with

import Blockly from 'blockly/core';

(note no *) has worked fine (and similarly for all the other entrypoints).

As the sources for the entrypoints (core/blockly.ts, blocks/blocks.ts, etc.) do not explicitly declare a default export, however, this should not be relied upon: when we start shipping Blockly as pure-ESM there will be no default export and so import Blockly from … will stop working.

We have for some time promulgated

   import * as Blockly from 'blockly/core';

as the correct way to import Blockly in our documentation.
Update our own plugins and templates to match.

Because we have been packaging Blockly until now only as CJS
modules, and CJS modules always provide an (unnamed) default
export consisting of the module.exports object, importing
Blockly with

    import Blockly from 'blockly/core';

(note no "*") has worked fine (and similarly for all the
other entrypoints).

As the sources for the entrypoints (core/blockly.ts,
blocks/blocks.ts, etc.) do not explicitly declare a default
export, however, this should not be relied upon: when we start
shipping Blockly as pure-ESM there will be no default export
and so "import Blockly from …" will stop working.
@cpcallen cpcallen added category: plugin Anything in the plugins folder cleanup labels May 2, 2024
@cpcallen cpcallen requested a review from a team as a code owner May 2, 2024 10:12
@cpcallen cpcallen requested review from maribethb and removed request for a team May 2, 2024 10:12
@cpcallen cpcallen merged commit 9af40b9 into google:master May 9, 2024
9 checks passed
@cpcallen cpcallen deleted the fix/imports branch May 9, 2024 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: plugin Anything in the plugins folder cleanup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants