Skip to content

Commit 4ed7be8

Browse files
authored
Use fork-ts-checker-webpack-plugin to typecheck during webpack (#449)
1 parent 560b6f0 commit 4ed7be8

File tree

13 files changed

+203
-30
lines changed

13 files changed

+203
-30
lines changed

workspaces/adventure-pack/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"@types/react-syntax-highlighter": "15.5.13",
7676
"cross-env": "7.0.3",
7777
"eslint": "9.11.1",
78+
"fork-ts-checker-webpack-plugin": "9.0.2",
7879
"jest": "29.7.0",
7980
"prettier": "3.3.3",
8081
"prettier-plugin-java": "2.6.4",

workspaces/adventure-pack/webpack.config.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { execSync } from "node:child_process";
22
import path from "node:path";
33

4-
import webpack, { type Configuration } from "webpack";
4+
import { DefinePlugin, type Configuration } from "webpack";
5+
import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
56

67
import { WEB_APP_DIST } from "./src/scripts/build/constants.ts";
78

@@ -24,7 +25,6 @@ const config: Configuration = {
2425
{
2526
loader: "ts-loader",
2627
options: {
27-
// TODO: Consider using fork-ts-checker-webpack-plugin for typechecking.
2828
transpileOnly: true,
2929
},
3030
},
@@ -39,9 +39,11 @@ const config: Configuration = {
3939
},
4040

4141
plugins: [
42-
new webpack.DefinePlugin({
42+
new DefinePlugin({
4343
ADVENTURE_PACK_COMMIT_HASH: JSON.stringify(commitHash),
4444
}),
45+
46+
new ForkTsCheckerWebpackPlugin(),
4547
],
4648

4749
optimization: {

workspaces/download-leetcode-submissions/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"@types/node": "22.7.4",
3333
"cross-env": "7.0.3",
3434
"eslint": "9.11.1",
35+
"fork-ts-checker-webpack-plugin": "9.0.2",
3536
"prettier": "3.3.3",
3637
"ts-loader": "9.5.1",
3738
"tsx": "4.19.1",

workspaces/download-leetcode-submissions/webpack.config.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { builtinModules } from "node:module";
22
import path from "node:path";
33

4-
import webpack, {
4+
import {
5+
BannerPlugin,
56
type Configuration,
67
type ExternalItemFunctionData,
78
} from "webpack";
9+
import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
810

911
import { stripPrefix } from "@code-chronicles/util/stripPrefix";
1012
import { stripPrefixOrThrow } from "@code-chronicles/util/stripPrefixOrThrow";
@@ -28,7 +30,6 @@ const config: Configuration = {
2830
{
2931
loader: "ts-loader",
3032
options: {
31-
// TODO: Consider using fork-ts-checker-webpack-plugin for typechecking.
3233
transpileOnly: true,
3334
},
3435
},
@@ -53,11 +54,13 @@ const config: Configuration = {
5354
),
5455

5556
plugins: [
56-
new webpack.BannerPlugin({
57+
new BannerPlugin({
5758
banner: "#!/usr/bin/env node\n",
5859
raw: true,
5960
entryOnly: true,
6061
}),
62+
63+
new ForkTsCheckerWebpackPlugin(),
6164
],
6265
};
6366

workspaces/fetch-leetcode-problem-list/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"@types/node": "22.7.4",
3131
"cross-env": "7.0.3",
3232
"eslint": "9.11.1",
33+
"fork-ts-checker-webpack-plugin": "9.0.2",
3334
"prettier": "3.3.3",
3435
"ts-loader": "9.5.1",
3536
"tsx": "4.19.1",

workspaces/fetch-leetcode-problem-list/webpack.config.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import { chmod } from "node:fs/promises";
22
import { builtinModules } from "node:module";
33
import path from "node:path";
44

5-
import webpack, {
5+
import {
6+
BannerPlugin,
67
type Compiler,
78
type Configuration,
89
type ExternalItemFunctionData,
910
} from "webpack";
11+
import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
1012

1113
import { stripPrefix } from "@code-chronicles/util/stripPrefix";
1214
import { stripPrefixOrThrow } from "@code-chronicles/util/stripPrefixOrThrow";
@@ -16,7 +18,7 @@ import packageJson from "./package.json" with { type: "json" };
1618
class WebpackMakeOutputExecutablePlugin {
1719
// eslint-disable-next-line class-methods-use-this -- This is the interface expected by webpack.
1820
apply(compiler: Compiler): void {
19-
compiler.hooks.afterEmit.tapAsync(
21+
compiler.hooks.afterEmit.tapPromise(
2022
"WebpackMakeOutputExecutablePlugin",
2123
async (compilation) => {
2224
const promises: Promise<void>[] = [];
@@ -59,7 +61,6 @@ const config: Configuration = {
5961
{
6062
loader: "ts-loader",
6163
options: {
62-
// TODO: Consider using fork-ts-checker-webpack-plugin for typechecking.
6364
transpileOnly: true,
6465
},
6566
},
@@ -84,13 +85,15 @@ const config: Configuration = {
8485
),
8586

8687
plugins: [
87-
new webpack.BannerPlugin({
88+
new BannerPlugin({
8889
banner: "#!/usr/bin/env node\n",
8990
raw: true,
9091
entryOnly: true,
9192
}),
9293

9394
new WebpackMakeOutputExecutablePlugin(),
95+
96+
new ForkTsCheckerWebpackPlugin(),
9497
],
9598
};
9699

workspaces/fetch-recent-accepted-leetcode-submissions/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"@types/node": "22.7.4",
3131
"cross-env": "7.0.3",
3232
"eslint": "9.11.1",
33+
"fork-ts-checker-webpack-plugin": "9.0.2",
3334
"prettier": "3.3.3",
3435
"ts-loader": "9.5.1",
3536
"tsx": "4.19.1",

workspaces/fetch-recent-accepted-leetcode-submissions/webpack.config.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { builtinModules } from "node:module";
22
import path from "node:path";
33

4-
import webpack, {
4+
import {
5+
BannerPlugin,
56
type Configuration,
67
type ExternalItemFunctionData,
78
} from "webpack";
9+
import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
810

911
import { stripPrefix } from "@code-chronicles/util/stripPrefix";
1012
import { stripPrefixOrThrow } from "@code-chronicles/util/stripPrefixOrThrow";
@@ -28,7 +30,6 @@ const config: Configuration = {
2830
{
2931
loader: "ts-loader",
3032
options: {
31-
// TODO: Consider using fork-ts-checker-webpack-plugin for typechecking.
3233
transpileOnly: true,
3334
},
3435
},
@@ -53,11 +54,13 @@ const config: Configuration = {
5354
),
5455

5556
plugins: [
56-
new webpack.BannerPlugin({
57+
new BannerPlugin({
5758
banner: "#!/usr/bin/env node\n",
5859
raw: true,
5960
entryOnly: true,
6061
}),
62+
63+
new ForkTsCheckerWebpackPlugin(),
6164
],
6265
};
6366

workspaces/leetcode-zen-mode/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"@types/node": "22.7.4",
3131
"cross-env": "7.0.3",
3232
"eslint": "9.11.1",
33+
"fork-ts-checker-webpack-plugin": "9.0.2",
3334
"prettier": "3.3.3",
3435
"ts-loader": "9.5.1",
3536
"tsx": "4.19.1",

workspaces/leetcode-zen-mode/webpack.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import path from "node:path";
22

33
import type { Configuration } from "webpack";
4+
import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
45

56
import packageJson from "./package.json" with { type: "json" };
67

@@ -20,7 +21,6 @@ const config: Configuration = {
2021
{
2122
loader: "ts-loader",
2223
options: {
23-
// TODO: Consider using fork-ts-checker-webpack-plugin for typechecking.
2424
transpileOnly: true,
2525
},
2626
},
@@ -33,6 +33,8 @@ const config: Configuration = {
3333
resolve: {
3434
conditionNames: ["import"],
3535
},
36+
37+
plugins: [new ForkTsCheckerWebpackPlugin()],
3638
};
3739

3840
export default config;

0 commit comments

Comments
 (0)