Skip to content

Commit

Permalink
build-bundle.js: default to bundling genesis devices
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed Nov 27, 2019
1 parent 24cfb17 commit 6db19c4
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions scripts/build-bundle.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
import bundleSource from '@agoric/bundle-source';

async function main(argv, { open, rollup, resolvePlugin, pathResolve }) {
async function main(argv, pkg, { open, rollup, resolvePlugin, pathResolve }) {
if (argv.length < 4) {
throw new Error('usage: bundle startFilename dest');
for (const dev of ['mailbox', 'command', 'timer']) {
const [startFilename, dest] = [`${pkg}/src/devices/${dev}-src.js`, `${pkg}/src/bundles/${dev}-src.js`];
await bundle1(startFilename, dest);
}
} else {
const [startFilename, dest] = argv.slice(2, 4);
await bundle1(startFilename, dest);
}
const [startFilename, dest] = argv.slice(2, 4);

const { source, sourceMap } = await bundleSource(
startFilename,
'getExport',
{ rollup, resolvePlugin, pathResolve },
);
const actualSource = `export default ${source}\n${sourceMap}`;
const f = await open(dest, 'w', 0o644);
await f.write(actualSource);
await f.close();
}
async function bundle1(startFilename, dest) {
console.log(`bundle: ${startFilename} -> ${dest}`);
const { source, sourceMap } = await bundleSource(
startFilename,
'getExport',
{ rollup, resolvePlugin, pathResolve },
);
const actualSource = `export default ${source}\n${sourceMap}`;
const f = await open(dest, 'w', 0o644);
await f.write(actualSource);
await f.close();
}

}


/** Access ambient authority only if invoked as script. */
if (typeof require !== 'undefined' && typeof module !== 'undefined') {
main(process.argv, {
main(process.argv, `${__dirname}/..`, {
open: require('fs').promises.open,
rollup: require('rollup').rollup,
pathResolve: require('path').resolve,
Expand Down

0 comments on commit 6db19c4

Please sign in to comment.