Skip to content

chore: do not provide polyfills on bundling @babel/standalone#12909

Merged
JLHwung merged 3 commits intobabel:mainfrom
JLHwung:fix-12907
Feb 26, 2021
Merged

chore: do not provide polyfills on bundling @babel/standalone#12909
JLHwung merged 3 commits intobabel:mainfrom
JLHwung:fix-12907

Conversation

@JLHwung
Copy link
Copy Markdown
Contributor

@JLHwung JLHwung commented Feb 25, 2021

Q                       A
Fixed Issues? Fixes #12907
Patch: Bug Fix? Y
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

The issue #12907 was introduced in #12458, where we injected require("module") in the polyfill for require.resolve(_, { paths }). However, we should not inject it when bundling @babel/standalone, because require("module") is not available in browsers.

@JLHwung JLHwung added PR: Bug Fix 🐛 A type of pull request used for our changelog categories i: regression labels Feb 25, 2021
@babel-bot
Copy link
Copy Markdown
Collaborator

babel-bot commented Feb 25, 2021

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/42855/

@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci Bot commented Feb 25, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 00d4226:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

Comment thread babel.config.js
Comment on lines 78 to +82
unambiguousSources.push("packages/babel-runtime/regenerator");
// fall through
convertESM = false;
ignoreLib = false;
// rollup-commonjs will converts node_modules to ESM
unambiguousSources.push(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: we can merge the unambiguousSources.push calls.

Copy link
Copy Markdown
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

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

This PR fixes the regression, but I'll also open a PR (to babel-polyfills I think) to fix the underlying problem: require.resolve shouldn't even be loaded in the bundle since it's meant to run in the browser; similarly to how we don't bundle fs-specific files for @babel/core.

@nicolo-ribaudo
Copy link
Copy Markdown
Member

I released @babel/helper-define-polyfill-provider@0.1.4. Could you update it in yarn.lock so that we remove Node-specific code from @babel/standalone?

@JLHwung JLHwung merged commit bfd30b9 into babel:main Feb 26, 2021
@JLHwung JLHwung deleted the fix-12907 branch February 26, 2021 22:10
This was referenced Mar 5, 2021
This was referenced Mar 8, 2021
@github-actions github-actions Bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 29, 2021
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Importing babel/standalone results in compilation error with Webpack

4 participants