forked from Agoric/agoric-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build-bundle like build-kernel but for devices, etc.
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import bundleSource from '@agoric/bundle-source'; | ||
|
||
async function main(argv, { open, rollup, resolvePlugin, pathResolve }) { | ||
if (argv.length < 4) { | ||
throw new Error('usage: bundle 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(); | ||
} | ||
|
||
|
||
|
||
/** Access ambient authority only if invoked as script. */ | ||
if (typeof require !== 'undefined' && typeof module !== 'undefined') { | ||
main(process.argv, { | ||
open: require('fs').promises.open, | ||
rollup: require('rollup').rollup, | ||
pathResolve: require('path').resolve, | ||
resolvePlugin: require('rollup-plugin-node-resolve'), | ||
}).then( | ||
_ => process.exit(0), | ||
err => { | ||
console.log('error creating bundle:'); | ||
console.log(err); | ||
process.exit(1); | ||
}, | ||
); | ||
} | ||
|