forked from samchon/typia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
40 lines (39 loc) · 1.13 KB
/
rollup.config.js
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
const path = require("path");
const typescript = require("@rollup/plugin-typescript");
const nodeResolve = require("@rollup/plugin-node-resolve");
const commomnjs = require("@rollup/plugin-commonjs");
module.exports = {
input: "./src/index.ts",
output: {
dir: "./lib",
format: "esm",
sourcemap: true,
entryFileNames: (chunkInfo) => {
const ext = `mjs`
const externalDir = `_external`;
const nodeModulesDir = `node_modules`;
if (chunkInfo.name.includes(nodeModulesDir)) {
/** replace / to _ and the last part of the path is the file name */
const nameSplit = chunkInfo.name.split('/')
const chunkName = path.join(externalDir, nameSplit.slice(0, -1).join('_'), nameSplit.at(-1))
console.table({
before: chunkInfo.name,
after: chunkName,
})
return `${chunkName}.${ext}`;
}
return `[name].${ext}`;
},
preserveModules: true,
preserveModulesRoot: "src",
},
plugins: [
nodeResolve(),
commomnjs(),
typescript({
tsconfig: "tsconfig.json",
module: "ESNext",
target: "ESNext",
}),
],
};