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
|
const rollup = require('rollup');
const path = require('path');
const nodeResolve = require('@rollup/plugin-node-resolve').nodeResolve;
const commonjs = require('@rollup/plugin-commonjs');
const json = require('@rollup/plugin-json');
//const license = require('rollup-plugin-license');
async function main() {
await Promise.all([
bundleDependency('process-es6'),
bundleDependency('buffer-es6'),
bundleDependency('browserify-fs'),
bundleDependency('crypto-browserify'),
])
}
async function bundleDependency(depName) {
const bundle = await rollup.rollup({
input: depName,
plugins: [
nodeResolve({
browser: true,
preferBuiltins: true,
moduleDirectories: ['node_modules','/usr/share/nodejs','/usr/lib/nodejs']
}),
commonjs(),
// license({
// thirdParty: {
// output: path.join(__dirname, '..', 'polyfills', `LICENSE-${depName}.txt`),
// includePrivate: true, // Default is false.
// encoding: 'utf-8', // Default is utf-8.
// }
// }),
json(),
],
external: [
'crypto',
'vm',
'events',
'path',
'stream',
'util',
'buffer'
]
});
await bundle.write({
format: 'esm',
file: path.join('polyfills', depName + '.js')
});
}
main();
|