-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
rollup.config.js
52 lines (51 loc) · 1.59 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
/**
* 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: [
"module", "util", "os", "path", "debug", "fs", "import-fresh",
"strip-json-comments", "assert", "ignore", "minimatch", "url", "ajv",
"globals"
],
treeshake: false,
output: {
format: "cjs",
file: "dist/eslintrc.cjs",
sourcemap: true,
freeze: false
},
plugins: [importMetaURLPlugin()]
},
{
input: "./lib/index-universal.js",
external: [
"module", "util", "os", "path", "debug", "fs", "import-fresh",
"strip-json-comments", "assert", "ignore", "minimatch", "url", "ajv",
"globals"
],
treeshake: false,
output: {
format: "cjs",
file: "dist/eslintrc-universal.cjs",
sourcemap: true,
freeze: false
}
}
];