Skip to content

Commit b698943

Browse files
committed
Revert "ci: replace esbuild with rspack"
This reverts commit b99a0e0.
1 parent da6588a commit b698943

3 files changed

Lines changed: 19 additions & 98 deletions

File tree

builder/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@
1010
},
1111
"devDependencies": {
1212
"@npmcli/package-json": "^7.0.5",
13-
"@rspack/core": "^1.7.11",
1413
"@types/node": "^24.12.2",
1514
"@types/npmcli__package-json": "^4.0.4",
1615
"@typescript-eslint/eslint-plugin": "^8.58.2",
1716
"@typescript-eslint/parser": "^8.58.2",
1817
"@typescriptprime/parsing": "^2.0.1",
1918
"chokidar": "^5.0.0",
19+
"esbuild": "^0.28.0",
2020
"eslint": "^10.2.1",
21-
"memfs": "^4.57.2",
2221
"tldts": "^7.0.28",
2322
"tsx": "^4.21.0",
2423
"typescript": "^6.0.3",

builder/source/build.ts

Lines changed: 18 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import * as RsPack from '@rspack/core'
2-
import * as Memfs from 'memfs'
1+
import * as ESBuild from 'esbuild'
32
import * as Zod from 'zod'
43
import * as Process from 'node:process'
54
import * as Path from 'node:path'
65
import PackageJson from '@npmcli/package-json'
76
import { CreateBanner } from './banner/index.js'
87
import { SafeInitCwd } from './utils/safe-init-cwd.js'
9-
import { RunCompiler } from './utils/awaited-rspack.js'
108

119
export type BuildOptions = {
1210
Minify: boolean
@@ -47,87 +45,25 @@ export async function Build(OptionsParam?: BuildOptions): Promise<void> {
4745
}
4846
})
4947

50-
const TypescriptLoader = {
51-
test: /\.ts$/,
52-
exclude: ['/node_modules/'],
53-
loader: 'builtin:swc-loader',
54-
options: {
55-
jsc: {
56-
parser: {
57-
syntax: 'typescript',
58-
decorators: true,
59-
dynamicImport: true
60-
}
61-
}
62-
},
63-
type: 'javascript/auto'
64-
} satisfies RsPack.RuleSetRule
65-
66-
const WorkerContainer = Memfs.createFsFromVolume(new Memfs.Volume())
67-
const WorkerBuilder = RsPack.rspack({
68-
entry: [Path.resolve(ProjectRoot, 'userscript', 'source', 'ocr-worker.ts')],
69-
mode: Options.BuildType,
70-
optimization: {
71-
minimize: Options.Minify
72-
},
73-
target: ['es2024', 'webworker'],
74-
output: {
75-
path: Path.resolve('/'),
76-
filename: 'ocr-worker.js'
77-
},
78-
resolve: {
79-
extensions: ['.ts', '.js', '.json'],
80-
extensionAlias: {
81-
'.js': ['.ts', '.js']
82-
}
83-
},
84-
module: {
85-
rules: [TypescriptLoader]
86-
}
48+
const WorkerCode = await ESBuild.build({
49+
entryPoints: [Path.resolve(ProjectRoot, 'userscript', 'source', 'ocr-worker.ts')],
50+
bundle: true,
51+
minify: Options.Minify,
52+
write: false,
53+
target: ['es2024', 'chrome119', 'firefox142', 'safari26']
8754
})
88-
//@ts-expect-error https://github.com/web-infra-dev/rspack/issues/5091
89-
WorkerBuilder.outputFileSystem = WorkerContainer
90-
await RunCompiler(WorkerBuilder)
9155

92-
const MainBuilder = RsPack.rspack({
93-
entry: [Path.resolve(ProjectRoot, 'userscript', 'source', 'index.ts')],
94-
mode: Options.BuildType,
95-
optimization: {
96-
minimize: Options.Minify,
97-
minimizer: [
98-
new RsPack.SwcJsMinimizerRspackPlugin({
99-
minimizerOptions: {
100-
format: {
101-
comments: 'all'
102-
}
103-
}
104-
})
105-
]
56+
await ESBuild.build({
57+
entryPoints: [Path.resolve(ProjectRoot, 'userscript', 'source', 'index.ts')],
58+
bundle: true,
59+
minify: Options.Minify,
60+
outfile: `${ProjectRoot}/dist/NamuLink${Options.BuildType === 'development' ? '.dev' : ''}.user.js`,
61+
banner: {
62+
js: Banner
10663
},
107-
plugins: [
108-
new RsPack.BannerPlugin({
109-
banner: Banner,
110-
raw: true
111-
}),
112-
new RsPack.DefinePlugin({
113-
__OCR_WORKER_CODE__: JSON.stringify(WorkerContainer.readFileSync(Path.resolve('/', 'ocr-worker.js'), 'utf-8'))
114-
})
115-
],
116-
output: {
117-
path: Path.resolve(ProjectRoot, 'dist'),
118-
filename: `NamuLink${Options.BuildType === 'development' ? '.dev' : ''}.user.js`
119-
},
120-
resolve: {
121-
extensions: ['.ts', '.js', '.json'],
122-
extensionAlias: {
123-
'.js': ['.ts', '.js']
124-
}
125-
},
126-
module: {
127-
rules: [TypescriptLoader]
128-
},
129-
target: ['es2024', 'web']
64+
target: ['es2024', 'chrome119', 'firefox142', 'safari26'],
65+
define: {
66+
__OCR_WORKER_CODE__: JSON.stringify(WorkerCode.outputFiles[0].text)
67+
}
13068
})
131-
132-
await RunCompiler(MainBuilder)
13369
}

builder/source/utils/awaited-rspack.ts

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

0 commit comments

Comments
 (0)