-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathrollup.config.mjs
55 lines (50 loc) · 1.53 KB
/
rollup.config.mjs
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
import rollupPluginJspm from '@jspm/plugin-rollup';
import { readFileSync, writeFileSync, readdirSync } from 'node:fs';
import rimraf from 'rimraf';
rimraf.sync('./nodelibs/browser');
// Patch call-bind, pending https://github.com/ljharb/call-bind/pull/8.
const callBindPath = './node_modules/call-bind/callBound.js';
writeFileSync(callBindPath, readFileSync(callBindPath, 'utf8').replace('./', 'call-bind'));
const input = Object.fromEntries(
[
...readdirSync('./src-browser'),
'assert/strict.js',
'fs/promises.js',
'dns/promises.js',
'path/posix.js',
'path/win32.js',
'stream/consumers.js',
'stream/promises.js',
'stream/web.js',
'timers/promises.js',
'util/types.js',
]
.filter(n => !n.startsWith('__') && n.endsWith('.js'))
.map(n => [n.slice(0, -3), './src-browser/' + n])
);
const jspmPlugin = rollupPluginJspm({
env: ['browser'],
inputMap: {
imports: {
// TODO: fix these cases in JSPM generator
'./node_modules/asn1.js/lib/asn1': './node_modules/asn1.js/lib/asn1.js',
'./node_modules/hash.js/lib/hash/sha': './node_modules/hash.js/lib/hash/sha.js',
'./node_modules/readable-stream/lib/stream': './node_modules/readable-stream/lib/stream.js',
punycode: './node_modules/punycode/punycode.js'
},
scopes: {
'./node_modules/': input
}
}
});
export default {
input,
output: {
dir: 'nodelibs/browser',
entryFileNames: '[name].js',
chunkFileNames: 'chunk-[hash].js',
format: 'esm'
},
onwarn () {},
plugins: [jspmPlugin]
}