Skip to content

Commit 6393e60

Browse files
Update runtime integration tests for Node.js >= 16.6 (#13923)
1 parent 76e4566 commit 6393e60

File tree

8 files changed

+75
-16
lines changed

8 files changed

+75
-16
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,18 @@ jobs:
391391
node-version: 14.2
392392
- name: Test Node.js 14.2
393393
run: yarn test:runtime:node
394+
- name: Use Node.js 16.5
395+
uses: actions/setup-node@v2-beta
396+
with:
397+
node-version: 16.5
398+
- name: Test Node.js 16.5
399+
run: yarn test:runtime:node
400+
- name: Use Node.js 16.6
401+
uses: actions/setup-node@v2-beta
402+
with:
403+
node-version: 16.6
404+
- name: Test Node.js 16.6
405+
run: yarn test:runtime:node
394406

395407
e2e-publish:
396408
name: Publish to local Verdaccio registry
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
================= require - auto ====================
2+
typeof objectWithoutProperties: function
3+
typeof objectWithoutProperties.default: function
4+
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 }
5+
================= require - esm =====================
6+
Error: Must use import to load ES Module: <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js
7+
require() of ES modules is not supported.
8+
require() of <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js from <ROOT>/test/runtime-integration/src/require-esm.cjs is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
9+
Instead rename toPrimitive.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from <ROOT>/packages/babel-runtime/helpers/esm/package.json.
10+
11+
=============== require - corejs ====================
12+
typeof Set: function
13+
arr: 1,2,3
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
================= require - auto ====================
2+
typeof objectWithoutProperties: function
3+
typeof objectWithoutProperties.default: function
4+
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 }
5+
================= require - esm =====================
6+
Error: Must use import to load ES Module: <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js
7+
require() of ES modules is not supported.
8+
require() of <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js from <ROOT>/test/runtime-integration/src/absolute/require-esm.cjs is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
9+
Instead rename toPrimitive.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from <ROOT>/packages/babel-runtime/helpers/esm/package.json.
10+
11+
=============== require - corejs ====================
12+
typeof Set: function
13+
arr: 1,2,3

test/runtime-integration/expected-cjs-absolute.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ typeof objectWithoutProperties: function
33
typeof objectWithoutProperties.default: function
44
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 }
55
================= require - esm =====================
6-
Error: Must use import to load ES Module: <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js
7-
require() of ES modules is not supported.
8-
require() of <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js from <ROOT>/test/runtime-integration/src/absolute/require-esm.cjs is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
9-
Instead rename toPrimitive.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from <ROOT>/packages/babel-runtime/helpers/esm/package.json.
10-
6+
Error: require() of ES Module <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js from <ROOT>/test/runtime-integration/src/absolute/require-esm.cjs not supported.
7+
Instead change the require of toPrimitive.js in <ROOT>/test/runtime-integration/src/absolute/require-esm.cjs to a dynamic import() which is available in all CommonJS modules.
118
=============== require - corejs ====================
129
typeof Set: function
1310
arr: 1,2,3

test/runtime-integration/expected-cjs.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ typeof objectWithoutProperties: function
33
typeof objectWithoutProperties.default: function
44
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 }
55
================= require - esm =====================
6-
Error: Must use import to load ES Module: <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js
7-
require() of ES modules is not supported.
8-
require() of <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js from <ROOT>/test/runtime-integration/src/require-esm.cjs is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
9-
Instead rename toPrimitive.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from <ROOT>/packages/babel-runtime/helpers/esm/package.json.
10-
6+
Error: require() of ES Module <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js from <ROOT>/test/runtime-integration/src/require-esm.cjs not supported.
7+
Instead change the require of toPrimitive.js in <ROOT>/test/runtime-integration/src/require-esm.cjs to a dynamic import() which is available in all CommonJS modules.
118
=============== require - corejs ====================
129
typeof Set: function
1310
arr: 1,2,3
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
================== import - auto ====================
2+
typeof inheritsLoose: function
3+
A.__proto__ === B true
4+
================= import - esm ======================
5+
typeof toArray: function
6+
arr: 1,2,3
7+
=============== import - corejs ====================
8+
typeof Set: function
9+
arr: 1,2,3
10+
================= require - auto ====================
11+
typeof objectWithoutProperties: function
12+
typeof objectWithoutProperties.default: function
13+
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 }
14+
================= require - esm =====================
15+
Error: Must use import to load ES Module: <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js
16+
require() of ES modules is not supported.
17+
require() of <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js from <ROOT>/test/runtime-integration/src/require-esm.cjs is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
18+
Instead rename toPrimitive.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from <ROOT>/packages/babel-runtime/helpers/esm/package.json.
19+
20+
=============== require - corejs ====================
21+
typeof Set: function
22+
arr: 1,2,3

test/runtime-integration/expected-esm.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@ typeof objectWithoutProperties: function
1212
typeof objectWithoutProperties.default: function
1313
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 }
1414
================= require - esm =====================
15-
Error: Must use import to load ES Module: <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js
16-
require() of ES modules is not supported.
17-
require() of <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js from <ROOT>/test/runtime-integration/src/require-esm.cjs is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
18-
Instead rename toPrimitive.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from <ROOT>/packages/babel-runtime/helpers/esm/package.json.
19-
15+
Error: require() of ES Module <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js from <ROOT>/test/runtime-integration/src/require-esm.cjs not supported.
16+
Instead change the require of toPrimitive.js in <ROOT>/test/runtime-integration/src/require-esm.cjs to a dynamic import() which is available in all CommonJS modules.
2017
=============== require - corejs ====================
2118
typeof Set: function
2219
arr: 1,2,3

test/runtime-integration/node.cjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ if (
1010
(major === 13 && minor >= 2)
1111
) {
1212
const expectedEsm =
13-
major === 13 && minor <= 3 ? "expected-esm-13.2.txt" : "expected-esm.txt";
13+
major === 13 && minor <= 3
14+
? "expected-esm-13.2.txt"
15+
: major < 16 || (major === 16 && minor <= 5)
16+
? "expected-esm-16.0.txt"
17+
: "expected-esm.txt";
1418

1519
test("ESM", "./src/main-esm.mjs", expectedEsm);
1620
// TODO: This never worked in any Babel version
@@ -24,6 +28,8 @@ const expectedCjs =
2428
? "expected-cjs-13.0.txt"
2529
: major === 13 && minor <= 3
2630
? "expected-cjs-13.2.txt"
31+
: major < 16 || (major === 16 && minor <= 5)
32+
? "expected-cjs-16.0.txt"
2733
: "expected-cjs.txt";
2834

2935
test("CJS", "./src/main-cjs.cjs", expectedCjs);
@@ -35,6 +41,8 @@ const expectedCjsAbsolute =
3541
? "expected-cjs-absolute-13.0.txt"
3642
: major === 13 && minor <= 3
3743
? "expected-cjs-absolute-13.2.txt"
44+
: major < 16 || (major === 16 && minor <= 5)
45+
? "expected-cjs-absolute-16.0.txt"
3846
: "expected-cjs-absolute.txt";
3947

4048
test(

0 commit comments

Comments
 (0)