Update runtime integration tests for Node.js >= 16.6 (#13923)

This commit is contained in:
Nicolò Ribaudo 2021-11-04 01:10:28 +01:00 committed by GitHub
parent 76e4566bfc
commit 6393e60a68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 75 additions and 16 deletions

View File

@ -391,6 +391,18 @@ jobs:
node-version: 14.2 node-version: 14.2
- name: Test Node.js 14.2 - name: Test Node.js 14.2
run: yarn test:runtime:node 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: e2e-publish:
name: Publish to local Verdaccio registry name: Publish to local Verdaccio registry

View File

@ -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

View File

@ -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

View File

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

View File

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

View File

@ -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

View File

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

View File

@ -10,7 +10,11 @@ if (
(major === 13 && minor >= 2) (major === 13 && minor >= 2)
) { ) {
const expectedEsm = 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); test("ESM", "./src/main-esm.mjs", expectedEsm);
// TODO: This never worked in any Babel version // TODO: This never worked in any Babel version
@ -24,6 +28,8 @@ const expectedCjs =
? "expected-cjs-13.0.txt" ? "expected-cjs-13.0.txt"
: major === 13 && minor <= 3 : major === 13 && minor <= 3
? "expected-cjs-13.2.txt" ? "expected-cjs-13.2.txt"
: major < 16 || (major === 16 && minor <= 5)
? "expected-cjs-16.0.txt"
: "expected-cjs.txt"; : "expected-cjs.txt";
test("CJS", "./src/main-cjs.cjs", expectedCjs); test("CJS", "./src/main-cjs.cjs", expectedCjs);
@ -35,6 +41,8 @@ const expectedCjsAbsolute =
? "expected-cjs-absolute-13.0.txt" ? "expected-cjs-absolute-13.0.txt"
: major === 13 && minor <= 3 : major === 13 && minor <= 3
? "expected-cjs-absolute-13.2.txt" ? "expected-cjs-absolute-13.2.txt"
: major < 16 || (major === 16 && minor <= 5)
? "expected-cjs-absolute-16.0.txt"
: "expected-cjs-absolute.txt"; : "expected-cjs-absolute.txt";
test( test(