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

Allow require() of runtime helpers in Node.js 13.2-13.6 #12893

Merged
merged 1 commit into from Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 12 additions & 12 deletions .github/workflows/ci.yml
Expand Up @@ -326,18 +326,18 @@ jobs:
node-version: "13.0" # quoted, otherwise it's just 13
- name: Test Node.js 13.0
run: yarn test:runtime:node
# - name: Use Node.js 13.2
# uses: actions/setup-node@v2-beta
# with:
# node-version: 13.2
# - name: Test Node.js 13.2
# run: yarn test:runtime:node
# - name: Use Node.js 13.6
# uses: actions/setup-node@v2-beta
# with:
# node-version: 13.6
# - name: Test Node.js 13.6
# run: yarn test:runtime:node
- name: Use Node.js 13.2
uses: actions/setup-node@v2-beta
with:
node-version: 13.2
- name: Test Node.js 13.2
run: yarn test:runtime:node
- name: Use Node.js 13.6
uses: actions/setup-node@v2-beta
with:
node-version: 13.6
- name: Test Node.js 13.6
run: yarn test:runtime:node
- name: Use Node.js 13.7
uses: actions/setup-node@v2-beta
with:
Expand Down
11 changes: 7 additions & 4 deletions packages/babel-plugin-transform-runtime/scripts/build-dist.js
Expand Up @@ -159,13 +159,16 @@ function writeHelpers(runtimeName, { corejs } = {}) {
// - Node.js >=13.7.0 and bundlers will succesfully load the first
// array entry:
// * Node.js will always load the CJS file
// * Bundlers when using require() will load the CJS file
// * Everything else will load the ESM file
// - Node.js <13.7.0 will fail resolving the first array entry, and will
// * Modern tools when using "import" will load the ESM file
// * Everything else (old tools, or requrie() in tools) will
// load the CJS file
// - Node.js 13.2-13.7 will ignore the "node" and "import" conditions,
// will fallback to "default" and load the CJS file
// - Node.js <13.2.0 will fail resolving the first array entry, and will
// fallback to the second entry (the CJS file)
// In Babel 8 we can simplify this.
helperSubExports[`./${helperPath}`] = [
{ node: cjs, require: cjs, default: esm },
{ node: cjs, import: esm, default: cjs },
cjs,
];
// For backward compatibility. We can remove this in Babel 8.
Expand Down