-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
45 lines (41 loc) · 1.11 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
import { resolve, dirname, join } from 'path';
import { accessSync, F_OK } from 'fs';
const exists = (path) => {
try {
accessSync(path, F_OK);
return true;
} catch (e) {
return false;
}
}
const maps = [
{
key: '@temperlang/core',
value: resolve('temper.out/js/temper-core/index.js'),
},
]
const start = 'internal/index.js';
export default {
input: start,
output: {
file: 'out/index.js',
},
plugins: [
{
resolveId: (importee, importer) => {
if (start === importee) {
return start;
}
if (/^(?:\.\/|\.\.\/|\/)/.test(importee)) {
return join(dirname(importer), importee);
}
for (const {key, value} of maps) {
if (key === importee || (key instanceof RegExp && key.test(importee))) {
return join(value, importee.replace(key, ''));
}
}
return join(resolve('temper.out/js'), importee)
},
},
],
};