-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.mjs
75 lines (71 loc) · 1.98 KB
/
rollup.config.mjs
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
import dts from "rollup-plugin-dts";
import esbuild from "rollup-plugin-esbuild";
import json from "@rollup/plugin-json";
// https://stackblitz.com/edit/node-gcuwxg?file=rollup.config.mjs
import { createRequire } from "module";
const require = createRequire(import.meta.url);
const pkg = require("./package.json");
const name = "index", sharedGlobals = {
path: "path",
fs: "fs"
};
export const config = [
{
external: [
...(Object.keys(pkg.devDependencies) || {}),
...(Object.keys(pkg.peerDependencies) || {}),
// ...(Object.keys(packageJson.dependencies) || {}),
"node:path"
,
"fs",
"puppeteer-extra-plugin-repl/index"
],
input: "./src/index.ts",
plugins: [
// tsconfigPaths(),
// nodeResolve(
// {
// moduleDirectories: ["node_modules"]
// extensions: [".mjs", ".ts", ".json",".ts"]
// }
// ),
// json(),
esbuild({
platform: "node",
target: "node14",
sourceMap: true, // default
// optimizeDeps: {
// include: ["postinstall-postinstall","hast-util-classnames", "hast-util-from-html", "hast-util-select", "hast-util-to-mdast", "hast-util-to-nlcst", "mdast-util-to-markdown", "parse-english", "patch-package", "postinstall-postinstall", "unist-util-filter", "unist-util-flat-filter", "unist-util-inspect", "unist-util-reduce", "unist-util-remove"]
// },
loaders: {
// Add .json files support
// require @rollup/plugin-commonjs
".json": "json"
}
})
],
output: [
{
file: `dist/cjs/${name}.js`,
format: "cjs",
sourcemap: true,
globals: sharedGlobals
},
{
file: `dist/esm/${name}.js`,
format: "es",
sourcemap: true,
globals: sharedGlobals
}
]
},
{
input: "./src/index.ts",
plugins: [dts()],
output: {
file: `dist/types/${name}.d.ts`,
format: "es"
}
}
];
export default config;