chore: Testing changes related to Node 23 (#16951)

Co-authored-by: Huáng Jùnliàng <[email protected]>
This commit is contained in:
liuxingbaoyu
2024-11-08 18:01:06 +01:00
committed by GitHub
co-authored by Huáng Jùnliàng
parent 1d35c79f76
commit 7370b815fc
18 changed files with 125 additions and 55 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ aliases:
executors:
node-executor:
docker:
- image: cimg/node:22.10
- image: cimg/node:current
working_directory: ~/babel
jobs:
+23 -18
View File
@@ -19,7 +19,7 @@ jobs:
- name: Use Node.js latest
uses: actions/setup-node@v4
with:
node-version: 22
node-version: latest
check-latest: true
cache: "yarn"
- name: 'Check or update Yarn cache (fix w/ "yarn install")'
@@ -40,7 +40,7 @@ jobs:
- name: Use Node.js latest
uses: actions/setup-node@v4
with:
node-version: 22
node-version: latest
check-latest: true
cache: "yarn"
- name: 'Check for unmet constraints (fix w/ "yarn constraints --fix")'
@@ -69,7 +69,7 @@ jobs:
- name: Use Node.js latest
uses: actions/setup-node@v4
with:
node-version: 22
node-version: latest
check-latest: true
cache: "yarn"
- name: Generate coverage report
@@ -104,7 +104,6 @@ jobs:
run: yarn jest --ci
env:
BABEL_ENV: test
NODE_OPTIONS: ${{matrix.node-version == '23' && '--disable-warning=ExperimentalWarning' || ''}}
USE_ESM: true
build:
@@ -120,7 +119,7 @@ jobs:
- name: Use Node.js latest
uses: actions/setup-node@v4
with:
node-version: 22
node-version: latest
check-latest: true
cache: "yarn"
- name: Build babel artifacts
@@ -166,7 +165,7 @@ jobs:
- name: Use Node.js latest
uses: actions/setup-node@v4
with:
node-version: 22
node-version: latest
check-latest: true
cache: "yarn"
- name: Build babel artifacts
@@ -191,7 +190,7 @@ jobs:
- name: Use Node.js latest
uses: actions/setup-node@v4
with:
node-version: 22
node-version: latest
check-latest: true
cache: "yarn"
- name: Install
@@ -214,14 +213,14 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [23, 20, 18, 16, 14, 12, 10, 8, 6]
node-version: [22, 20, 18, 16, 14, 12, 10, 8, 6]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Use Node.js latest # Run yarn on latest node
uses: actions/setup-node@v4
with:
node-version: 22
node-version: latest
check-latest: true
cache: "yarn"
- name: Install
@@ -270,7 +269,7 @@ jobs:
if: matrix.node-version == '6' || matrix.node-version == '8' || matrix.node-version == '10'
uses: actions/setup-node@v4
with:
node-version: 22
node-version: latest
build-babel8:
name: Build Babel 8 Artifacts
@@ -285,7 +284,7 @@ jobs:
- name: Use Node.js latest
uses: actions/setup-node@v4
with:
node-version: 22
node-version: latest
check-latest: true
cache: "yarn"
- name: Use ESM
@@ -361,7 +360,7 @@ jobs:
- name: Use Node.js latest
uses: actions/setup-node@v4
with:
node-version: 22
node-version: latest
check-latest: true
cache: "yarn"
- name: Install
@@ -386,7 +385,7 @@ jobs:
- name: Use Node.js latest
uses: actions/setup-node@v4
with:
node-version: 22
node-version: latest
check-latest: true
cache: "yarn"
- name: Install
@@ -415,7 +414,7 @@ jobs:
- name: Use Node.js latest
uses: actions/setup-node@v4
with:
node-version: 22
node-version: latest
check-latest: true
cache: "yarn"
# See https://github.com/babel/babel/pull/12906
@@ -511,6 +510,12 @@ jobs:
node-version: 16.6
- name: Test Node.js 16.6
run: node test/runtime-integration/node.cjs
- name: Use Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22
- name: Test Node.js 22
run: node test/runtime-integration/node.cjs
eslint7-test:
name: Test @babel/eslint-* with ESLint 7.5.0
@@ -522,7 +527,7 @@ jobs:
- name: Use Node.js latest
uses: actions/setup-node@v4
with:
node-version: 22
node-version: latest
check-latest: true
cache: "yarn"
- name: Install
@@ -547,7 +552,7 @@ jobs:
- name: Use Node.js latest
uses: actions/setup-node@v4
with:
node-version: 22
node-version: latest
check-latest: true
cache: "yarn"
- name: Install
@@ -572,7 +577,7 @@ jobs:
- name: Use Node.js latest
uses: actions/setup-node@v4
with:
node-version: 22
node-version: latest
check-latest: true
- name: Checkout test runner
uses: actions/checkout@v4
@@ -609,7 +614,7 @@ jobs:
- name: Use Node.js latest
uses: actions/setup-node@v4
with:
node-version: 22
node-version: latest
check-latest: true
- name: Install
run: yarn install
+2 -2
View File
@@ -25,7 +25,7 @@ jobs:
- name: Use Node.js latest
uses: actions/setup-node@v4
with:
node-version: 22
node-version: "*"
cache: "yarn"
- name: Use ESM
run: make use-esm
@@ -71,7 +71,7 @@ jobs:
- name: Use Node.js latest
uses: actions/setup-node@v4
with:
node-version: 22
node-version: "*"
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
+2 -2
View File
@@ -25,7 +25,7 @@ jobs:
- name: Use Node.js latest
uses: actions/setup-node@v4
with:
node-version: 22
node-version: "*"
cache: "yarn"
- name: Publish
run: ./scripts/integration-tests/publish-local.sh
@@ -64,7 +64,7 @@ jobs:
- name: Use Node.js latest
uses: actions/setup-node@v4
with:
node-version: 22
node-version: "*"
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
+1 -1
View File
@@ -22,7 +22,7 @@ jobs:
- name: Use Node.js latest
uses: actions/setup-node@v4
with:
node-version: 22
node-version: "*"
- name: Get latest kangax/compat-table commit
id: lastCommit
run: echo "sha1=$(./scripts/update-compat-table/get-last-commit.sh)" >> $GITHUB_OUTPUT
+1 -1
View File
@@ -25,7 +25,7 @@ jobs:
- name: Use Node.js latest
uses: actions/setup-node@v4
with:
node-version: 22
node-version: "*"
cache: "yarn"
- name: Get latest test262 version
id: test262
@@ -50,7 +50,7 @@ jobs:
- name: Use Node.js latest
uses: actions/setup-node@v4
with:
node-version: 22
node-version: "*"
cache: "yarn"
- name: Install and build
-1
View File
@@ -8,7 +8,6 @@ packages/babel-standalone/examples/**
packages/babel-parser/test/expressions/**
scripts/integration-tests/fixtures/**
packages/babel-parser/test/schema.json
test/runtime-integration/node.cjs
CHANGELOG.md
.github/*.md
+1 -1
View File
@@ -135,7 +135,7 @@ describe("browserslist", () => {
loadOptionsSync({
cwd: join(cwd, "fixtures", "targets"),
filename: "./node_modules/dep/test.js",
babelrcRoots: ["./node_modules/dep"],
babelrcRoots: ["./node_modules/dep/"],
}).targets,
).toEqual({ edge: "14.0.0" });
});
@@ -474,7 +474,7 @@ function normalizeOutput(
) {
const dir = path.resolve(
path.dirname(fileURLToPath(import.meta.url)),
"../../..",
"../../../",
);
const symbol = "<CWD>";
let result = code
@@ -920,7 +920,14 @@ export function buildProcessTests(
: [test.binLoc];
args = args.concat(opts.args);
const env = { ...process.env, FORCE_COLOR: "false", ...opts.env };
const env = {
...process.env,
FORCE_COLOR: "false",
...(parseInt(process.versions.node) >= 23 && {
NODE_OPTIONS: "--disable-warning=ExperimentalWarning",
}),
...opts.env,
};
const child = spawn(process.execPath, args, {
env,
cwd: tmpLoc,
+7 -1
View File
@@ -413,7 +413,13 @@ describe("@babel/register", function () {
function spawnNodeAsync(args, cwd = __dirname, env = process.env) {
const spawn = child.spawn(process.execPath, args, {
cwd,
env,
env: {
...env,
...(parseInt(process.versions.node) >= 23 && {
NODE_OPTIONS:
"--disable-warning=ExperimentalWarning " + (env.NODE_OPTIONS || ""),
}),
},
});
let output = "";
@@ -0,0 +1,10 @@
================= require - auto ====================
typeof objectWithoutProperties: function
typeof objectWithoutProperties.default: function
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 }
================= require - esm =====================
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
@@ -0,0 +1,10 @@
================= require - auto ====================
typeof objectWithoutProperties: function
typeof objectWithoutProperties.default: function
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 }
================= require - esm =====================
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
@@ -3,8 +3,9 @@ typeof objectWithoutProperties: function
typeof objectWithoutProperties.default: function
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 }
================= require - esm =====================
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.
typeof toPrimitive: object
typeof toPrimitive.default: function
Value: 2
=============== require - corejs ====================
typeof Set: function
arr: 1,2,3
+3 -2
View File
@@ -3,8 +3,9 @@ typeof objectWithoutProperties: function
typeof objectWithoutProperties.default: function
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 }
================= require - esm =====================
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.
typeof toPrimitive: object
typeof toPrimitive.default: function
Value: 2
=============== require - corejs ====================
typeof Set: function
arr: 1,2,3
@@ -0,0 +1,19 @@
================== 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: 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
+3 -2
View File
@@ -12,8 +12,9 @@ typeof objectWithoutProperties: function
typeof objectWithoutProperties.default: function
obj: { b: 2, [Symbol(Symbol.toStringTag)]: 5 }
================= require - esm =====================
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.
typeof toPrimitive: object
typeof toPrimitive.default: function
Value: 2
=============== require - corejs ====================
typeof Set: function
arr: 1,2,3
+29 -18
View File
@@ -13,8 +13,10 @@ if (
major === 13 && minor <= 3
? "expected-esm-13.2.txt"
: major < 16 || (major === 16 && minor <= 5)
? "expected-esm-16.0.txt"
: "expected-esm.txt";
? "expected-esm-16.0.txt"
: major < 23
? "expected-esm-22.txt"
: "expected-esm.txt";
test("ESM", "./src/main-esm.mjs", expectedEsm);
// TODO: This never worked in any Babel version
@@ -25,12 +27,14 @@ const expectedCjs =
major === 10 || (major === 12 && minor < 12.17)
? "expected-cjs-10.txt"
: major === 13 && minor <= 1
? "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";
? "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"
: major < 23
? "expected-cjs-22.txt"
: "expected-cjs.txt";
test("CJS", "./src/main-cjs.cjs", expectedCjs);
@@ -38,12 +42,14 @@ const expectedCjsAbsolute =
major === 10 || (major === 12 && minor < 12.17)
? "expected-cjs-absolute-10.txt"
: major === 13 && minor <= 1
? "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";
? "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"
: major < 23
? "expected-cjs-absolute-22.txt"
: "expected-cjs-absolute.txt";
test(
"CJS - absoluteRuntime",
@@ -57,10 +63,15 @@ function test(title, command, expectedName) {
console.log(`Testing with Node.js ${process.version} - ${title}`);
const out = normalize(
cp.execSync(`node ${command}`, {
cwd: __dirname,
encoding: "utf8",
})
cp.execSync(
`node ${
major >= 23 ? "--disable-warning=ExperimentalWarning " : ""
}${command}`,
{
cwd: __dirname,
encoding: "utf8",
}
)
);
if (expected === out) {