Skip to content

Commit e980484

Browse files
test: fix
1 parent bf8e904 commit e980484

16 files changed

Lines changed: 54 additions & 92 deletions

File tree

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"target": "esnext",
44
"allowImportingTsExtensions": true,
55
"rewriteRelativeImportExtensions": true,
6-
"verbatimModuleSyntax": true,
7-
"module": "commonjs"
6+
"module": "esnext"
87
}
98
}

test/build/config-format/typescript-cjs-using-nodejs/typescript.test.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@ const { resolve } = require("path");
55

66
describe("webpack cli", () => {
77
it("should support typescript esnext file", async () => {
8-
const [major, minor] = process.versions.node.split(".").map(Number);
9-
const { exitCode, stderr, stdout } = await run(__dirname, ["-c", "./webpack.config.cts"], {
10-
env: {
11-
NODE_NO_WARNINGS: 1,
12-
// Due nyc logic
13-
WEBPACK_CLI_FORCE_LOAD_ESM_CONFIG: true,
8+
const [major] = process.versions.node.split(".").map(Number);
9+
const { exitCode, stderr, stdout } = await run(
10+
__dirname,
11+
["-c", "./webpack.config.ts", "--disable-interpret"],
12+
{
13+
env: {
14+
NODE_NO_WARNINGS: 1,
15+
// Due nyc logic
16+
WEBPACK_CLI_FORCE_LOAD_ESM_CONFIG: true,
17+
},
18+
// Fallback to `ts-node/esm` for old Node.js versions
19+
nodeOptions: major >= 24 ? [] : ["--experimental-loader=ts-node/esm"],
1420
},
15-
// Fallback to `ts-node/esm` for old Node.js versions
16-
nodeOptions: major >= 22 && minor >= 6 ? [] : ["--experimental-loader=ts-node/esm"],
17-
});
21+
);
1822

1923
expect(stderr).toBeFalsy(); // Deprecation warning logs on stderr
2024
expect(stdout).toBeTruthy();

test/build/config-format/typescript-mjs-using-nodejs/webpack.config.mts renamed to test/build/config-format/typescript-cjs-using-nodejs/webpack.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable node/no-unsupported-features/es-syntax */
21
import * as path from "path";
32

43
// cspell:ignore elopment

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"target": "esnext",
44
"allowImportingTsExtensions": true,
55
"rewriteRelativeImportExtensions": true,
6-
"verbatimModuleSyntax": true,
76
"module": "esnext"
87
}
98
}

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@ const { resolve } = require("path");
55

66
describe("webpack cli", () => {
77
it("should support typescript esnext file", async () => {
8-
const [major, minor] = process.versions.node.split(".").map(Number);
9-
const { exitCode, stderr, stdout } = await run(__dirname, ["-c", "./webpack.config.mts"], {
10-
env: {
11-
NODE_NO_WARNINGS: 1,
12-
// Due nyc logic
13-
WEBPACK_CLI_FORCE_LOAD_ESM_CONFIG: true,
8+
const [major] = process.versions.node.split(".").map(Number);
9+
const { exitCode, stderr, stdout } = await run(
10+
__dirname,
11+
["-c", "./webpack.config.ts", "--disable-interpret"],
12+
{
13+
env: {
14+
NODE_NO_WARNINGS: 1,
15+
// Due nyc logic
16+
WEBPACK_CLI_FORCE_LOAD_ESM_CONFIG: true,
17+
},
18+
// Fallback to `ts-node/esm` for old Node.js versions
19+
nodeOptions: major >= 24 ? [] : ["--experimental-loader=ts-node/esm"],
1420
},
15-
// Fallback to `ts-node/esm` for old Node.js versions
16-
nodeOptions: major >= 22 && minor >= 6 ? [] : ["--experimental-loader=ts-node/esm"],
17-
});
21+
);
1822

1923
expect(stderr).toBeFalsy(); // Deprecation warning logs on stderr
2024
expect(stdout).toBeTruthy();

test/build/config-format/typescript-cjs-using-nodejs/webpack.config.cts renamed to test/build/config-format/typescript-mjs-using-nodejs/webpack.config.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
/* eslint-disable node/no-unsupported-features/es-syntax */
2-
const path = require("path");
1+
import * as path from "path";
32

43
// cspell:ignore elopment
54
const mode: string = "dev" + "elopment";
@@ -12,4 +11,4 @@ const config = {
1211
},
1312
};
1413

15-
module.exports = config;
14+
export default config;

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ describe("webpack cli", () => {
66
it("should support typescript file", async () => {
77
const [major, minor] = process.versions.node.split(".").map(Number);
88
const { exitCode, stderr, stdout } = await run(__dirname, ["-c", "./webpack.config.ts"], {
9-
env: {
10-
NODE_NO_WARNINGS: 1,
11-
// Due nyc logic
12-
WEBPACK_CLI_FORCE_LOAD_ESM_CONFIG: true,
13-
},
9+
env: { NODE_NO_WARNINGS: 1 },
1410
nodeOptions:
1511
major >= 22 && minor >= 6
1612
? ["--no-experimental-strip-types", "--require=ts-node/register"]

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

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/build/config-format/typescript-using-interpret/package.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/build/config-format/typescript-using-interpret/tsconfig.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)