-
Notifications
You must be signed in to change notification settings - Fork 15
/
rspack.config.js
92 lines (89 loc) · 2.01 KB
/
rspack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import { defineConfig } from "@rspack/cli";
import { rspack } from "@rspack/core";
import { RsdoctorRspackPlugin } from "@rsdoctor/rspack-plugin";
import { readFile } from "node:fs/promises";
import { execSync } from "node:child_process";
import { join } from "path";
import { fileURLToPath } from "url";
const __dirname = fileURLToPath(new URL(".", import.meta.url));
const packagemeta = JSON.parse(await readFile("package.json"));
export default defineConfig({
mode: "development",
entry: {
shared: join(__dirname, "src/shared/index.ts"),
worker: join(__dirname, "src/worker/index.ts"),
client: join(__dirname, "src/client/index.ts"),
controller: join(__dirname, "src/controller/index.ts"),
sync: join(__dirname, "src/sync.ts"),
},
resolve: {
extensions: [".ts", ".js"],
},
module: {
rules: [
{
test: /\.ts$/,
loader: "builtin:swc-loader",
exclude: ["/node_modules/"],
options: {
asdasdasds: new Error(),
jsc: {
parser: {
syntax: "typescript",
},
target: "es2022",
},
strictMode: false,
module: {
type: "es6",
strict: false,
strictMode: false,
},
},
type: "javascript/auto",
},
],
parser: {
javascript: {
dynamicImportMode: "eager",
},
},
},
output: {
filename: "scramjet.[name].js",
path: join(__dirname, "dist"),
libraryTarget: "es2022",
iife: true,
},
plugins: [
new rspack.ProvidePlugin({
dbg: [join(__dirname, "src/log.ts"), "default"],
}),
new rspack.DefinePlugin({
VERSION: JSON.stringify(packagemeta.version),
}),
new rspack.DefinePlugin({
COMMITHASH: (() => {
try {
let hash = JSON.stringify(
execSync("git rev-parse --short HEAD", {
encoding: "utf-8",
}).replace(/\r?\n|\r/g, "")
);
return hash;
} catch (e) {
return "unknown";
}
})(),
}),
process.env.DEBUG === "true"
? new RsdoctorRspackPlugin({
supports: {
parseBundle: true,
banner: true,
},
})
: null,
],
target: "webworker",
});