forked from Blair2004/NexoPOS
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathesmify.js
More file actions
35 lines (27 loc) · 740 Bytes
/
esmify.js
File metadata and controls
35 lines (27 loc) · 740 Bytes
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
export default function esmify(options) {
const cache = new Map();
const normalize = (id) => {
if (cache.has(id)) {
return cache.get(id);
}
const parts = id.split("/node_modules/");
const dirPaths = parts[parts.length - 1].split("/");
let n = `npm~${dirPaths[0]}`;
if (dirPaths[0][0] == "@") {
n = `npm~${dirPaths[0]}~${dirPaths[1]}}`;
}
cache.set(id, n);
return n;
};
return {
name: "rollup-plugin-multiple-vendors",
outputOptions(o) {
o.manualChunks = ( id, api ) => {
if (id.includes("node_modules")) {
return normalize(id);
}
};
return o;
},
};
}