forked from web-infra-dev/rspack
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for typescript config file
- Loading branch information
1 parent
d34238a
commit 2d5c4c9
Showing
5 changed files
with
49 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@rspack/cli": minor | ||
--- | ||
|
||
Support TypeScript as configuration 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 @@ | ||
console.log("Main typescript file"); |
12 changes: 12 additions & 0 deletions
12
packages/rspack-cli/tests/build/typescript/rspack.config.ts
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,12 @@ | ||
import * as path from "path"; | ||
|
||
const config = { | ||
mode: "production", | ||
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,5 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs" | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
packages/rspack-cli/tests/build/typescript/typescript.test.ts
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,26 @@ | ||
import { run } from "../../utils/test-utils"; | ||
import { existsSync } from "fs"; | ||
import { resolve } from "path"; | ||
|
||
describe("webpack cli", () => { | ||
it("should support default config in typescript", async () => { | ||
const { exitCode, stderr, stdout } = await run(__dirname, []); | ||
|
||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toBeTruthy(); | ||
expect(exitCode).toBe(0); | ||
expect(existsSync(resolve(__dirname, "dist/foo.bundle.js"))).toBeTruthy(); | ||
}); | ||
|
||
it("should support specifying config in typescript", async () => { | ||
const { exitCode, stderr, stdout } = await run(__dirname, [ | ||
"-c", | ||
"./rspack.config.ts" | ||
]); | ||
|
||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toBeTruthy(); | ||
expect(exitCode).toBe(0); | ||
expect(existsSync(resolve(__dirname, "dist/foo.bundle.js"))).toBeTruthy(); | ||
}); | ||
}); |