Skip to content

Commit

Permalink
Update runtime integration tests for Node.js >= 16.6 (#13923)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Nov 4, 2021
1 parent 76e4566 commit 6393e60
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 16 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -391,6 +391,18 @@ jobs:
node-version: 14.2
- name: Test Node.js 14.2
run: yarn test:runtime:node
- name: Use Node.js 16.5
uses: actions/setup-node@v2-beta
with:
node-version: 16.5
- name: Test Node.js 16.5
run: yarn test:runtime:node
- name: Use Node.js 16.6
uses: actions/setup-node@v2-beta
with:
node-version: 16.6
- name: Test Node.js 16.6
run: yarn test:runtime:node

e2e-publish:
name: Publish to local Verdaccio registry
Expand Down
13 changes: 13 additions & 0 deletions test/runtime-integration/expected-cjs-16.0.txt
@@ -0,0 +1,13 @@
================= require - auto ====================
typeof objectWithoutProperties: function
typeof objectWithoutProperties.default: function
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 }
================= require - esm =====================
Error: Must use import to load ES Module: <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js
require() of ES modules is not supported.
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.
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.

=============== require - corejs ====================
typeof Set: function
arr: 1,2,3
13 changes: 13 additions & 0 deletions test/runtime-integration/expected-cjs-absolute-16.0.txt
@@ -0,0 +1,13 @@
================= require - auto ====================
typeof objectWithoutProperties: function
typeof objectWithoutProperties.default: function
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 }
================= require - esm =====================
Error: Must use import to load ES Module: <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js
require() of ES modules is not supported.
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.
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.

=============== require - corejs ====================
typeof Set: function
arr: 1,2,3
7 changes: 2 additions & 5 deletions test/runtime-integration/expected-cjs-absolute.txt
Expand Up @@ -3,11 +3,8 @@ typeof objectWithoutProperties: function
typeof objectWithoutProperties.default: function
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 }
================= require - esm =====================
Error: Must use import to load ES Module: <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js
require() of ES modules is not supported.
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.
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.

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.
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.
=============== require - corejs ====================
typeof Set: function
arr: 1,2,3
7 changes: 2 additions & 5 deletions test/runtime-integration/expected-cjs.txt
Expand Up @@ -3,11 +3,8 @@ typeof objectWithoutProperties: function
typeof objectWithoutProperties.default: function
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 }
================= require - esm =====================
Error: Must use import to load ES Module: <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js
require() of ES modules is not supported.
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.
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.

Error: require() of ES Module <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js from <ROOT>/test/runtime-integration/src/require-esm.cjs not supported.
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.
=============== require - corejs ====================
typeof Set: function
arr: 1,2,3
22 changes: 22 additions & 0 deletions test/runtime-integration/expected-esm-16.0.txt
@@ -0,0 +1,22 @@
================== import - auto ====================
typeof inheritsLoose: function
A.__proto__ === B true
================= import - esm ======================
typeof toArray: function
arr: 1,2,3
=============== import - corejs ====================
typeof Set: function
arr: 1,2,3
================= require - auto ====================
typeof objectWithoutProperties: function
typeof objectWithoutProperties.default: function
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 }
================= require - esm =====================
Error: Must use import to load ES Module: <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js
require() of ES modules is not supported.
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.
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.

=============== require - corejs ====================
typeof Set: function
arr: 1,2,3
7 changes: 2 additions & 5 deletions test/runtime-integration/expected-esm.txt
Expand Up @@ -12,11 +12,8 @@ typeof objectWithoutProperties: function
typeof objectWithoutProperties.default: function
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 }
================= require - esm =====================
Error: Must use import to load ES Module: <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js
require() of ES modules is not supported.
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.
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.

Error: require() of ES Module <ROOT>/packages/babel-runtime/helpers/esm/toPrimitive.js from <ROOT>/test/runtime-integration/src/require-esm.cjs not supported.
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.
=============== require - corejs ====================
typeof Set: function
arr: 1,2,3
10 changes: 9 additions & 1 deletion test/runtime-integration/node.cjs
Expand Up @@ -10,7 +10,11 @@ if (
(major === 13 && minor >= 2)
) {
const expectedEsm =
major === 13 && minor <= 3 ? "expected-esm-13.2.txt" : "expected-esm.txt";
major === 13 && minor <= 3
? "expected-esm-13.2.txt"
: major < 16 || (major === 16 && minor <= 5)
? "expected-esm-16.0.txt"
: "expected-esm.txt";

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

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

test(
Expand Down

0 comments on commit 6393e60

Please sign in to comment.