Skip to content

Commit d8ab7a7

Browse files
ci: node.js@24 and rewrite tests
1 parent ac4938a commit d8ab7a7

File tree

30 files changed

+69
-32
lines changed

30 files changed

+69
-32
lines changed

.github/workflows/nodejs.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ jobs:
5858
strategy:
5959
matrix:
6060
os: [ubuntu-latest, windows-latest, macos-latest]
61-
node-version: [18.x, 20.x, 22.x, 23.x]
61+
node-version: [18.x, 20.x, 22.x, 24.x]
6262
shard: ["1/4", "2/4", "3/4", "4/4"]
6363
webpack-version: [latest]
6464
dev-server-version: [latest]
6565
exclude:
6666
# Node.js v23.7.0 is broken on windows
6767
- os: windows-latest
68-
node-version: 23.x
68+
node-version: 24.x
6969

7070
steps:
7171
- uses: actions/checkout@v4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
/* eslint-disable node/no-unsupported-features/es-syntax */
2-
/** eslint-disable **/
3-
import * as path from "path";
2+
const path = require("path");
43

54
// cspell:ignore elopment
65
const mode: string = "dev" + "elopment";
76
const config = {
87
mode,
98
entry: "./main.ts",
109
output: {
11-
path: path.resolve(__dirname, "dist"),
10+
path: path.resolve("dist"),
1211
filename: "foo.bundle.js",
1312
},
1413
};
1514

16-
export = config;
15+
module.exports = config;

test/build/config-format/typescript-commonjs-using-nodejs/tsconfig.json

-9
This file was deleted.

test/build/config-format/typescript-esnext-mjs/typescript.test.js renamed to test/build/config-format/typescript-mjs-using-nodejs/typescript.test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ const { resolve } = require("path");
55

66
describe("webpack cli", () => {
77
it("should support typescript esnext file", async () => {
8-
const env = { ...process.env };
9-
8+
const [major, minor] = process.versions.node.split(".").map(Number);
109
const { exitCode, stderr, stdout } = await run(__dirname, ["-c", "./webpack.config.mts"], {
11-
nodeOptions: ["--experimental-loader=ts-node/esm"],
12-
env,
10+
env: { NODE_NO_WARNINGS: 1 },
11+
// Fallback to `ts-node/esm` for old Node.js versions
12+
nodeOptions: major >= 22 && minor >= 6 ? [] : ["--experimental-loader=ts-node/esm"],
1313
});
1414

15-
expect(stderr).not.toBeFalsy(); // Deprecation warning logs on stderr
15+
expect(stderr).toBeFalsy(); // Deprecation warning logs on stderr
1616
expect(stdout).toBeTruthy();
1717
expect(exitCode).toBe(0);
1818
expect(existsSync(resolve(__dirname, "dist/foo.bundle.js"))).toBeTruthy();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("Rimuru Tempest");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"type": "module",
3+
"engines": {
4+
"node": ">=18.12.0"
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"compilerOptions": {
3+
"module": "esnext",
4+
"allowSyntheticDefaultImports": true
5+
}
6+
}

test/build/config-format/typescript-esnext/typescript.test.js renamed to test/build/config-format/typescript-ts-node-loader/typescript.test.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ const { resolve } = require("path");
55

66
describe("webpack cli", () => {
77
it("should support typescript esnext file", async () => {
8-
const env = { ...process.env };
9-
10-
env.WEBPACK_CLI_FORCE_LOAD_ESM_CONFIG = true;
11-
8+
const [major, minor] = process.versions.node.split(".").map(Number);
129
const { exitCode, stderr, stdout } = await run(__dirname, ["-c", "./webpack.config.ts"], {
13-
nodeOptions: ["--experimental-loader=ts-node/esm"],
14-
env,
10+
env: { NODE_NO_WARNINGS: 1 },
11+
nodeOptions:
12+
major >= 22 && minor >= 6
13+
? ["--no-experimental-strip-types", "--experimental-loader=ts-node/esm"]
14+
: ["--experimental-loader=ts-node/esm"],
1515
});
1616

17-
expect(stderr).not.toBeFalsy(); // Deprecation warning logs on stderr
17+
expect(stderr).toBeFalsy(); // Deprecation warning logs on stderr
1818
expect(stdout).toBeTruthy();
1919
expect(exitCode).toBe(0);
2020
expect(existsSync(resolve(__dirname, "dist/foo.bundle.js"))).toBeTruthy();

test/build/config-format/typescript/typescript.test.js renamed to test/build/config-format/typescript-ts-node-require/typescript.test.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ const { resolve } = require("path");
44

55
describe("webpack cli", () => {
66
it("should support typescript file", async () => {
7+
const [major, minor] = process.versions.node.split(".").map(Number);
78
const { exitCode, stderr, stdout } = await run(__dirname, ["-c", "./webpack.config.ts"], {
8-
// For `nyc`, remove it when we drop `nyc` usage
9-
nodeOptions: ["--require=ts-node/register"],
9+
env: { NODE_NO_WARNINGS: 1 },
10+
nodeOptions:
11+
major >= 22 && minor >= 6
12+
? ["--no-experimental-strip-types", "--require=ts-node/register"]
13+
: ["--require=ts-node/register"],
1014
});
1115

1216
expect(stderr).toBeFalsy();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}

test/build/config-format/typescript-commonjs-using-typescript/typescript.test.js renamed to test/build/config-format/typescript-using-interpret/typescript.test.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
// eslint-disable-next-line n/no-unpublished-require
12
const { run } = require("../../../utils/test-utils");
23
const { existsSync } = require("fs");
34
const { resolve } = require("path");
45

56
describe("webpack cli", () => {
67
it("should support typescript file", async () => {
78
const [major, minor] = process.versions.node.split(".").map(Number);
8-
const { exitCode, stderr, stdout } = await run(__dirname, ["-c", "./webpack.config.cts"], {
9+
const { exitCode, stderr, stdout } = await run(__dirname, ["-c", "./webpack.config.ts"], {
10+
env: { NODE_NO_WARNINGS: 1 },
911
nodeOptions: major >= 22 && minor >= 6 ? ["--no-experimental-strip-types"] : [],
1012
});
1113

test/build/config-format/typescript-commonjs-using-nodejs/webpack.config.cts renamed to test/build/config-format/typescript-using-interpret/webpack.config.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable node/no-unsupported-features/es-syntax */
21
/** eslint-disable **/
32
const path = require("path");
43

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("Rimuru Tempest");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"type": "module",
3+
"engines": {
4+
"node": ">=18.12.0"
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"compilerOptions": {
3+
"module": "esnext",
4+
"allowSyntheticDefaultImports": true
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import * as path from "path";
2+
3+
// cspell:ignore elopment
4+
const mode: string = "dev" + "elopment";
5+
const config = {
6+
mode,
7+
entry: "./main.ts",
8+
output: {
9+
path: path.resolve("dist"),
10+
filename: "foo.bundle.js",
11+
},
12+
};
13+
14+
export default config;

test/build/config-format/typescript/main.ts

-1
This file was deleted.

0 commit comments

Comments
 (0)