-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtsdown.config.ts
More file actions
52 lines (51 loc) 路 1.19 KB
/
Copy pathtsdown.config.ts
File metadata and controls
52 lines (51 loc) 路 1.19 KB
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
import terser from '@rollup/plugin-terser'
import MagicString from 'magic-string'
import treeShakeable from 'rollup-plugin-tree-shakeable'
import { defineConfig } from 'tsdown/config'
export default defineConfig([
{
entry: `src/index.js`,
platform: `neutral`,
sourcemap: `inline`,
dts: false,
publint: true,
plugins: [
{
name: `const-to-let`,
renderChunk(code) {
const magicString = new MagicString(code)
magicString.replaceAll(`const `, `let `)
return magicString.hasChanged()
? {
code: magicString.toString(),
map: magicString.generateMap({ hires: true }),
}
: null
},
},
terser({
ecma: 2020,
module: true,
toplevel: true,
compress: {
passes: 2,
unsafe: true,
unsafe_comps: true,
unsafe_math: true,
},
mangle: {
eval: true,
properties: {
builtins: true,
regex: `^_[^_]+`,
},
},
}),
treeShakeable(),
],
},
{
entry: `src/index.d.ts`,
dts: { emitDtsOnly: true },
},
])