Skip to content

Don't use require() in ESM files#12728

Merged
nicolo-ribaudo merged 2 commits intobabel:mainfrom
nicolo-ribaudo:fix-require-in-standalone
Feb 1, 2021
Merged

Don't use require() in ESM files#12728
nicolo-ribaudo merged 2 commits intobabel:mainfrom
nicolo-ribaudo:fix-require-in-standalone

Conversation

@nicolo-ribaudo
Copy link
Copy Markdown
Member

@nicolo-ribaudo nicolo-ribaudo commented Jan 31, 2021

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

This PR fixes a regression introduced by #12677.
Since require is a normal function in ES modules, rollup doesn't resolve it and thus the @babel/standalone bundle still contained require() calls.

This needs to be merged before the next release.

The first commit updates yarn-plugin-conditions, because nicolo-ribaudo/yarn-plugin-conditions@5b39955 makes it more bundler-friendly.

@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories Priority: High pkg: standalone labels Jan 31, 2021
@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci Bot commented Jan 31, 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 72d89fd:

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

@nicolo-ribaudo nicolo-ribaudo force-pushed the fix-require-in-standalone branch from 05413e8 to 72d89fd Compare January 31, 2021 21:16
@babel-bot
Copy link
Copy Markdown
Collaborator

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

Comment thread Gulpfile.mjs
"packages/babel-compat-data/*.js",
"packages/*/src/**/*.cjs",
],
}),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Q: Does the plugin reordering here resolve rollup/plugins#557?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, I don't get any error now. Btw, I swapped them because it's documented at https://github.com/rollup/plugins/tree/master/packages/babel#using-with-rollupplugin-commonjs

This means that we cannot use flow/TS in cjs files, but I couldn't find another way to make it work.

@nicolo-ribaudo nicolo-ribaudo merged commit 4f2d475 into babel:main Feb 1, 2021
@nicolo-ribaudo nicolo-ribaudo deleted the fix-require-in-standalone branch February 1, 2021 16:09
@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 4, 2021
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants