-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathrollup.config.js
62 lines (60 loc) · 1.52 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/** List of modules not included in the bundle. */
const external = [
"node:assert",
"node:fs",
"node:module",
"node:os",
"node:path",
"node:url",
"node:util",
"ajv",
"debug",
"globals",
"ignore",
"import-fresh",
"minimatch",
"strip-json-comments"
];
/**
* Custom Rollup plugin for `import.meta.url` transformation to commonjs.
* The default transformation ('file:' + __filename) does not check characters in __filename,
* and thus can produce invalid URLs, like in https://github.com/eslint/eslint/issues/15766
* See https://github.com/eslint/eslint/issues/15766#issuecomment-1093941321
* @returns {Object} Rollup plugin object.
*/
function importMetaURLPlugin() {
return {
name: "custom-import-meta-url",
resolveImportMeta(property) {
if (property === "url") {
return "require('url').pathToFileURL(__filename).toString()";
}
return null;
}
};
}
export default [
{
input: "./lib/index.js",
external,
treeshake: false,
output: {
format: "cjs",
file: "dist/eslintrc.cjs",
sourcemap: true,
freeze: false
},
plugins: [importMetaURLPlugin()]
},
{
input: "./lib/index-universal.js",
external,
treeshake: false,
output: {
format: "cjs",
file: "dist/eslintrc-universal.cjs",
sourcemap: true,
freeze: false
}
}
];