-
-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
153 lines (146 loc) · 3.08 KB
/
rollup.config.mjs
File metadata and controls
153 lines (146 loc) · 3.08 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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import typescript from "@rollup/plugin-typescript"
import { nodeResolve } from "@rollup/plugin-node-resolve"
import json from "@rollup/plugin-json"
import commonjs from "@rollup/plugin-commonjs"
// Bundle the CLI entry point into a single CommonJS file.
// Exclude Node built-in so they remain as externals.
const external = [
"path",
"url",
"fs",
"module",
"os",
"worker_threads",
"node:path",
"node:url",
"node:fs",
"node:os",
"node:worker_threads",
]
function isExternal(id) {
return (
external.includes(id) ||
external.some((pkg) => id === pkg || id.startsWith(pkg + "/"))
)
}
export default [
// CLI entry point (CommonJS)
{
input: "src/herb-lint.ts",
output: {
file: "dist/herb-lint.js",
format: "cjs",
sourcemap: true,
},
external: isExternal,
plugins: [
nodeResolve(),
commonjs(),
json(),
typescript({
tsconfig: "./tsconfig.json",
rootDir: "src/",
module: "esnext",
}),
],
},
// Lint worker entry point (CommonJS - used by worker_threads)
{
input: "src/cli/lint-worker.ts",
output: {
file: "dist/lint-worker.js",
format: "cjs",
sourcemap: true,
},
external: isExternal,
plugins: [
nodeResolve(),
commonjs(),
json(),
typescript({
tsconfig: "./tsconfig.json",
rootDir: "src/",
module: "esnext",
}),
],
},
// Library exports (ESM)
{
input: "src/index.ts",
output: {
file: "dist/index.js",
format: "esm",
sourcemap: true,
},
external: ["@herb-tools/core", "@herb-tools/node-wasm", "picomatch", "tinyglobby"],
plugins: [
nodeResolve(),
json(),
typescript({
tsconfig: "./tsconfig.json",
declaration: true,
declarationDir: "./dist/types",
rootDir: "src/",
}),
],
},
// Library exports (CommonJS)
{
input: "src/index.ts",
output: {
file: "dist/index.cjs",
format: "cjs",
sourcemap: true,
},
external: ["@herb-tools/core", "@herb-tools/node-wasm", "picomatch", "tinyglobby"],
plugins: [
nodeResolve(),
commonjs(),
json(),
typescript({
tsconfig: "./tsconfig.json",
rootDir: "src/",
module: "esnext",
}),
],
},
// Loader entry point (includes custom rule loader)
{
input: "src/loader.ts",
output: {
file: "dist/loader.js",
format: "esm",
sourcemap: true,
},
external,
plugins: [
nodeResolve({ preferBuiltins: true }),
commonjs(),
json(),
typescript({
tsconfig: "./tsconfig.json",
declaration: true,
declarationDir: "./dist/types",
rootDir: "src/",
}),
],
},
{
input: "src/loader.ts",
output: {
file: "dist/loader.cjs",
format: "cjs",
sourcemap: true,
},
external,
plugins: [
nodeResolve({ preferBuiltins: true }),
commonjs(),
json(),
typescript({
tsconfig: "./tsconfig.json",
rootDir: "src/",
}),
],
},
]