-
-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improved support for
.cts
and .mts
extensions
- Loading branch information
1 parent
73bd2cc
commit a77daf2
Showing
23 changed files
with
206 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const { run } = require("../../../utils/test-utils"); | ||
|
||
describe("webpack cli", () => { | ||
it("should support mjs config format", async () => { | ||
const { exitCode, stderr, stdout } = await run(__dirname, ["-c", "webpack.config.mjs"]); | ||
|
||
expect(exitCode).toBe(0); | ||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log("Main typescript file"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs" | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
test/build/config-format/typescript-commonjs/typescript.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const { run } = require("../../../utils/test-utils"); | ||
const { existsSync } = require("fs"); | ||
const { resolve } = require("path"); | ||
|
||
describe("webpack cli", () => { | ||
it("should support typescript file", async () => { | ||
const { exitCode, stderr, stdout } = await run(__dirname, ["-c", "./webpack.config.cts"]); | ||
|
||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toBeTruthy(); | ||
expect(exitCode).toBe(0); | ||
expect(existsSync(resolve(__dirname, "dist/foo.bundle.js"))).toBeTruthy(); | ||
}); | ||
}); |
16 changes: 16 additions & 0 deletions
16
test/build/config-format/typescript-commonjs/webpack.config.cts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* eslint-disable node/no-unsupported-features/es-syntax */ | ||
/** eslint-disable **/ | ||
import * as path from "path"; | ||
|
||
// cspell:ignore elopment | ||
const mode: string = "dev" + "elopment"; | ||
const config = { | ||
mode, | ||
entry: "./main.ts", | ||
output: { | ||
path: path.resolve(__dirname, "dist"), | ||
filename: "foo.bundle.js", | ||
}, | ||
}; | ||
|
||
export = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log("Rimuru Tempest"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"type": "module", | ||
"engines": { | ||
"node": ">=14.15.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "esnext", | ||
"allowSyntheticDefaultImports": true | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
test/build/config-format/typescript-esnext-mjs/typescript.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// eslint-disable-next-line node/no-unpublished-require | ||
const { run } = require("../../../utils/test-utils"); | ||
const { existsSync } = require("fs"); | ||
const { resolve } = require("path"); | ||
|
||
describe("webpack cli", () => { | ||
it("should support typescript esnext file", async () => { | ||
const env = { ...process.env }; | ||
|
||
const { exitCode, stderr, stdout } = await run(__dirname, ["-c", "./webpack.config.mts"], { | ||
nodeOptions: ["--experimental-loader=ts-node/esm"], | ||
env, | ||
}); | ||
|
||
expect(stderr).not.toBeFalsy(); // Deprecation warning logs on stderr | ||
expect(stdout).toBeTruthy(); | ||
expect(exitCode).toBe(0); | ||
expect(existsSync(resolve(__dirname, "dist/foo.bundle.js"))).toBeTruthy(); | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
test/build/config-format/typescript-esnext-mjs/webpack.config.mts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* eslint-disable node/no-unsupported-features/es-syntax */ | ||
import * as path from "path"; | ||
|
||
// cspell:ignore elopment | ||
const mode: string = "dev" + "elopment"; | ||
const config = { | ||
mode, | ||
entry: "./main.ts", | ||
output: { | ||
path: path.resolve("dist"), | ||
filename: "foo.bundle.js", | ||
}, | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters