2020-03-10 20:55:00 +00:00
|
|
|
const {unlinkSync} = require("fs");
|
2020-03-09 23:08:49 +00:00
|
|
|
const {writeSync} = require("tempy");
|
2020-03-09 22:57:04 +00:00
|
|
|
const {name} = require("./package.json");
|
2020-03-10 19:50:59 +00:00
|
|
|
|
|
|
|
const nullTemp = writeSync("export default null;", {extension: "mjs"});
|
|
|
|
const nullRouted = new Set([
|
|
|
|
"cacache",
|
|
|
|
"socks-proxy-agent",
|
|
|
|
"ssri",
|
|
|
|
"stripJsonComments",
|
|
|
|
"encoding",
|
|
|
|
]);
|
|
|
|
|
|
|
|
const fnTemp = writeSync("export default () => () => {};", {extension: "mjs"});
|
|
|
|
const fnRouted = new Set([
|
|
|
|
"depd",
|
|
|
|
"debug",
|
|
|
|
]);
|
2020-03-09 23:02:01 +00:00
|
|
|
|
2020-03-09 22:57:04 +00:00
|
|
|
module.exports = {
|
|
|
|
input: `${name}.js`,
|
|
|
|
output: {
|
|
|
|
file: name,
|
|
|
|
name,
|
|
|
|
format: "cjs",
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
require("rollup-plugin-hashbang")(),
|
2020-03-10 19:50:59 +00:00
|
|
|
require("@rollup/plugin-json")({
|
|
|
|
indent: "",
|
|
|
|
preferConst: true,
|
|
|
|
}),
|
2020-05-20 17:11:06 +00:00
|
|
|
require("@rollup/plugin-node-resolve").default({
|
2020-03-09 22:57:04 +00:00
|
|
|
customResolveOptions: {
|
2020-03-10 19:50:59 +00:00
|
|
|
packageFilter: pkg => {
|
|
|
|
if (nullRouted.has(pkg.name)) return {main: nullTemp, type: "module"};
|
|
|
|
if (fnRouted.has(pkg.name)) return {main: fnTemp, type: "module"};
|
2020-03-09 22:57:04 +00:00
|
|
|
return pkg;
|
2020-03-10 19:50:59 +00:00
|
|
|
},
|
2020-03-09 22:57:04 +00:00
|
|
|
}
|
|
|
|
}),
|
2020-03-10 19:50:59 +00:00
|
|
|
require("@rollup/plugin-commonjs")({
|
|
|
|
sourceMap: false,
|
|
|
|
}),
|
|
|
|
require("rollup-plugin-terser").terser({
|
|
|
|
output: {comments: false},
|
|
|
|
}),
|
2020-03-09 22:57:04 +00:00
|
|
|
],
|
|
|
|
};
|
2020-03-10 20:55:00 +00:00
|
|
|
|
|
|
|
process.on("exit", () => {
|
|
|
|
unlinkSync(nullTemp);
|
|
|
|
unlinkSync(fnTemp);
|
|
|
|
});
|