diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce02e9ec1d1f..03782d03a3f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/test/runtime-integration/expected-cjs-16.0.txt b/test/runtime-integration/expected-cjs-16.0.txt new file mode 100644 index 000000000000..7d29d238b301 --- /dev/null +++ b/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: /packages/babel-runtime/helpers/esm/toPrimitive.js +require() of ES modules is not supported. +require() of /packages/babel-runtime/helpers/esm/toPrimitive.js from /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 /packages/babel-runtime/helpers/esm/package.json. + +=============== require - corejs ==================== +typeof Set: function +arr: 1,2,3 diff --git a/test/runtime-integration/expected-cjs-absolute-16.0.txt b/test/runtime-integration/expected-cjs-absolute-16.0.txt new file mode 100644 index 000000000000..57e260d567f6 --- /dev/null +++ b/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: /packages/babel-runtime/helpers/esm/toPrimitive.js +require() of ES modules is not supported. +require() of /packages/babel-runtime/helpers/esm/toPrimitive.js from /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 /packages/babel-runtime/helpers/esm/package.json. + +=============== require - corejs ==================== +typeof Set: function +arr: 1,2,3 diff --git a/test/runtime-integration/expected-cjs-absolute.txt b/test/runtime-integration/expected-cjs-absolute.txt index 57e260d567f6..baf2a3a8fdfb 100644 --- a/test/runtime-integration/expected-cjs-absolute.txt +++ b/test/runtime-integration/expected-cjs-absolute.txt @@ -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: /packages/babel-runtime/helpers/esm/toPrimitive.js -require() of ES modules is not supported. -require() of /packages/babel-runtime/helpers/esm/toPrimitive.js from /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 /packages/babel-runtime/helpers/esm/package.json. - +Error: require() of ES Module /packages/babel-runtime/helpers/esm/toPrimitive.js from /test/runtime-integration/src/absolute/require-esm.cjs not supported. +Instead change the require of toPrimitive.js in /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 diff --git a/test/runtime-integration/expected-cjs.txt b/test/runtime-integration/expected-cjs.txt index 7d29d238b301..0e2a3083fd52 100644 --- a/test/runtime-integration/expected-cjs.txt +++ b/test/runtime-integration/expected-cjs.txt @@ -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: /packages/babel-runtime/helpers/esm/toPrimitive.js -require() of ES modules is not supported. -require() of /packages/babel-runtime/helpers/esm/toPrimitive.js from /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 /packages/babel-runtime/helpers/esm/package.json. - +Error: require() of ES Module /packages/babel-runtime/helpers/esm/toPrimitive.js from /test/runtime-integration/src/require-esm.cjs not supported. +Instead change the require of toPrimitive.js in /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 diff --git a/test/runtime-integration/expected-esm-16.0.txt b/test/runtime-integration/expected-esm-16.0.txt new file mode 100644 index 000000000000..dc7fd12b703c --- /dev/null +++ b/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: /packages/babel-runtime/helpers/esm/toPrimitive.js +require() of ES modules is not supported. +require() of /packages/babel-runtime/helpers/esm/toPrimitive.js from /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 /packages/babel-runtime/helpers/esm/package.json. + +=============== require - corejs ==================== +typeof Set: function +arr: 1,2,3 diff --git a/test/runtime-integration/expected-esm.txt b/test/runtime-integration/expected-esm.txt index dc7fd12b703c..3f911dddc92b 100644 --- a/test/runtime-integration/expected-esm.txt +++ b/test/runtime-integration/expected-esm.txt @@ -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: /packages/babel-runtime/helpers/esm/toPrimitive.js -require() of ES modules is not supported. -require() of /packages/babel-runtime/helpers/esm/toPrimitive.js from /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 /packages/babel-runtime/helpers/esm/package.json. - +Error: require() of ES Module /packages/babel-runtime/helpers/esm/toPrimitive.js from /test/runtime-integration/src/require-esm.cjs not supported. +Instead change the require of toPrimitive.js in /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 diff --git a/test/runtime-integration/node.cjs b/test/runtime-integration/node.cjs index f87d44035156..527dbbd54dce 100644 --- a/test/runtime-integration/node.cjs +++ b/test/runtime-integration/node.cjs @@ -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 @@ -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); @@ -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(