Skip to content

Commit 7fe8520

Browse files
lukecotterclaude
andcommitted
refactor: replace SWC with rolldown built-in minification and CJS interop
Rolldown natively handles TypeScript transpilation, minification, and CJS-to-ESM interop, making the rollup-plugin-swc3 dependency and the eventemitter3 alias unnecessary in the rolldown config. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8a05d59 commit 7fe8520

1 file changed

Lines changed: 3 additions & 17 deletions

File tree

rolldown.config.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,13 @@ import nodePolyfills from '@rolldown/plugin-node-polyfills';
66
// rollup plugins
77
import copy from 'rollup-plugin-copy';
88
import postcss from 'rollup-plugin-postcss';
9-
import { defineRollupSwcOption, swc } from 'rollup-plugin-swc3';
109

1110
import path from 'path';
1211
import { fileURLToPath } from 'url';
1312

1413
const __filename = fileURLToPath(import.meta.url);
1514
const __dirname = path.dirname(__filename);
1615

17-
const getSwcOptions = (dirPath: string) =>
18-
defineRollupSwcOption({
19-
include: /\.[mc]?[jt]sx?$/,
20-
exclude: 'node_modules',
21-
tsconfig: production ? `${dirPath}/tsconfig.json` : `${dirPath}/tsconfig-dev.json`,
22-
jsc: {
23-
transform: { useDefineForClassFields: false },
24-
minify: {
25-
compress: production ? { keep_classnames: true, keep_fnames: true } : false,
26-
mangle: production ? { keep_classnames: true } : false,
27-
},
28-
},
29-
});
30-
3116
/**
3217
* Workaround for oxc printer lone-surrogate bug (https://github.com/oxc-project/oxc/issues/3526).
3318
* The oxc codegen replaces lone surrogates (0xD800-0xDFFF) with U+FFFD in long CJS strings,
@@ -66,6 +51,7 @@ export default defineConfig([
6651
chunkFileNames: 'lana-[name].js',
6752
sourcemap: false,
6853
keepNames: true,
54+
minify: production,
6955
},
7056
tsconfig: production ? './lana/tsconfig.json' : './lana/tsconfig-dev.json',
7157
platform: 'node',
@@ -76,7 +62,7 @@ export default defineConfig([
7662
},
7763

7864
external: ['vscode'],
79-
plugins: [preserveAntlrATN(), swc(getSwcOptions('./lana'))],
65+
plugins: [preserveAntlrATN()],
8066
},
8167
{
8268
input: { bundle: './log-viewer/src/Main.ts' },
@@ -87,6 +73,7 @@ export default defineConfig([
8773
chunkFileNames: 'log-viewer-[name].js',
8874
sourcemap: false,
8975
keepNames: true,
76+
minify: production,
9077
},
9178
],
9279
platform: 'browser',
@@ -103,7 +90,6 @@ export default defineConfig([
10390
extensions: ['.css', '.scss'],
10491
minimize: true,
10592
}),
106-
swc(getSwcOptions('./log-viewer')),
10793
copy({
10894
hook: 'closeBundle',
10995
targets: [

0 commit comments

Comments
 (0)