-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
48 lines (44 loc) · 1.08 KB
/
rollup.config.mjs
File metadata and controls
48 lines (44 loc) · 1.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
import { builtinModules } from "node:module";
import typescript from "@rollup/plugin-typescript";
const externalModules = new Set([
...builtinModules,
...builtinModules.map((moduleName) => `node:${moduleName}`),
]);
function addCliShebang() {
return {
name: "add-cli-shebang",
generateBundle(_outputOptions, bundle) {
const cliChunk = bundle["cli.js"];
if (!cliChunk || cliChunk.type !== "chunk") {
return;
}
if (!cliChunk.code.startsWith("#!/usr/bin/env node")) {
cliChunk.code = `#!/usr/bin/env node\n${cliChunk.code}`;
}
},
};
}
export default {
input: {
index: "src/index.ts",
cli: "src/cli.ts",
},
output: {
dir: "dist",
format: "cjs",
sourcemap: true,
entryFileNames: "[name].js",
exports: "named",
},
external: (id) => externalModules.has(id) || id.startsWith("node:"),
plugins: [
typescript({
tsconfig: "./tsconfig.json",
module: "ESNext",
moduleResolution: "Bundler",
declaration: false,
declarationMap: false,
}),
addCliShebang(),
],
};