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

feat(build)!: Introduce ESM entrypoints #8091

Merged
merged 4 commits into from
May 10, 2024
Merged

Commits on May 10, 2024

  1. feat(build)!: Introduce ESM entrypoints for chunks

    Introduce an "import" conditional export for each of the chunk
    entrypoints (blockly/core, blockly/blocks, blockly/javascript
    etc.), and point these at wrappers created by build_tasks.js
    that import the corresponding <chunk>_compressed.js file and
    export its named exports.
    
    BREAKING CHANGE:
    
    Importing Blockly via
    
        import Blockly from 'blockly/core';
    
    (and similarly for the other chunk entrypoints) has worked until
    now because most build tools (including Webpack in particular)
    fuilfil the request for the default export of a CJS module by
    providing the module.exports object, rather than an
    explicitly-named default export as they would for an ES module.
    
    Since core/blockly.ts (the notional entrypoint for blockly/core)
    does not provide a default export, the wrappers created by this
    PR do not either.
    
    Code of the above form will therefore break, and should be updated
    to use a wildcard:
    
        import * as Blockly from 'blockly/core';
    cpcallen committed May 10, 2024
    Configuration menu
    Copy the full SHA
    4352902 View commit details
    Browse the repository at this point in the history
  2. feat(build)!: Introduce main package ESM entrypoint

    Introduce an "import" conditional export for the top-level
    package entrypoint (blockly), and point it at a wrappers
    created by build_tasks.js that imports the existing index.js
    file.
    
    BREAKING CHANGE:
    
    Importing Blockly via
    
        import Blockly from 'blockly';
    
    has worked until now because most build tools (including Webpack
    in particular) fuilfil the request for the default export of a
    CJS module by providing the module.exports object, rather than an
    explicitly-named default export as they would for an ES module.
    
    Since core/blockly.ts does not provide a default export, the
    wrapper created by this PR does not either.
    
    Code of the above form will therefore break, and should be updated
    to use a wildcard:
    
        import * as Blockly from 'blockly';
    cpcallen committed May 10, 2024
    Configuration menu
    Copy the full SHA
    670a4fd View commit details
    Browse the repository at this point in the history
  3. feat(build)!: Introduce ESM entrypoints for langfiles

    Introduce an "import" conditional export for each of the
    langfile entrypoints (msg/en, msg/fr, etc.),, and point them
    at wrappers created by build_tasks.js that import the
    existing <lang>.js file.
    
    BREAKING CHANGE:
    
    Importing languages via
    
        import en from 'blockly/msg/en';
    
    has worked until now because most build tools (including Webpack
    in particular) fuilfil the request for the default export of a
    CJS module by providing the module.exports object, rather than an
    explicitly-named default export as they would for an ES module.
    
    Code of the above form will therefore break, and should be updated
    to use a wildcard:
    
        import * as en from 'blockly/msg/en';
    cpcallen committed May 10, 2024
    Configuration menu
    Copy the full SHA
    30c2cec View commit details
    Browse the repository at this point in the history
  4. fix(typings): Remove bogus .d.ts file.

    For some reason we had a typings/msg/yue.d.ts that did not
    correxpond to any msg/json/yue.json.  Delete it.
    cpcallen committed May 10, 2024
    Configuration menu
    Copy the full SHA
    c3a2a66 View commit details
    Browse the repository at this point in the history