Skip to content

Commit

Permalink
fix: silence the builtin modules warning in agoric-cli deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Mar 23, 2020
1 parent fc046ec commit 9043516
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
11 changes: 8 additions & 3 deletions packages/agoric-cli/lib/deploy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable no-await-in-loop */
import builtinModules from 'builtin-modules';
import parseArgs from 'minimist';
import { evaluateProgram } from '@agoric/evaluate';
import { E, HandledPromise, makeCapTP } from '@agoric/captp';
Expand Down Expand Up @@ -55,7 +56,7 @@ export default async function deployMain(progname, rawArgs, powers) {

// Wait for the chain to become ready.
let bootP = getBootstrap();
log.error('Chain loaded:', await E.G(bootP).LOADING);
log.info('Chain loaded:', await E.G(bootP).LOADING);
// Take a new copy, since the chain objects have been added to bootstrap.
bootP = getBootstrap();

Expand All @@ -64,7 +65,11 @@ export default async function deployMain(progname, rawArgs, powers) {
const pathResolve = (...resArgs) =>
path.resolve(path.dirname(moduleFile), ...resArgs);
log('running', moduleFile);
const { source, sourceMap } = await bundleSource(moduleFile);
const { source, sourceMap } = await bundleSource(
moduleFile,
undefined,
{ externals: builtinModules },
);

const actualSource = `(${source}\n)\n${sourceMap}`;
const mainNS = evaluateProgram(actualSource, {
Expand All @@ -84,7 +89,7 @@ export default async function deployMain(progname, rawArgs, powers) {
}
}

log('Done!');
log.info('Done!');
ws.close();
exit.res(0);
} catch (e) {
Expand Down
1 change: 1 addition & 0 deletions packages/agoric-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@agoric/eventual-send": "^0.5.0",
"@agoric/make-promise": "^0.0.1",
"anylogger": "^0.21.0",
"builtin-modules": "^3.1.0",
"chalk": "^2.4.2",
"esm": "^3.2.25",
"minimist": "^1.2.0",
Expand Down
17 changes: 9 additions & 8 deletions packages/bundle-source/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,24 @@ const SUPPORTED_FORMATS = ['getExport', 'nestedEvaluate'];
export default async function bundleSource(
startFilename,
moduleFormat = DEFAULT_MODULE_FORMAT,
access = undefined,
powers = undefined,
) {
if (!SUPPORTED_FORMATS.includes(moduleFormat)) {
throw Error(`moduleFormat ${moduleFormat} is not implemented`);
}
const { commonjsPlugin, rollup, resolvePlugin, pathResolve } = access || {
rollup: rollup0,
resolvePlugin: resolve0,
commonjsPlugin: commonjs0,
pathResolve: path.resolve,
};
const {
commonjsPlugin = commonjs0,
rollup = rollup0,
resolvePlugin = resolve0,
pathResolve = path.resolve,
externals = [],
} = powers || {};
const resolvedPath = pathResolve(startFilename);
const bundle = await rollup({
input: resolvedPath,
treeshake: false,
preserveModules: moduleFormat === 'nestedEvaluate',
external: ['@agoric/evaluate', '@agoric/harden'],
external: ['@agoric/evaluate', '@agoric/harden', ...externals],
plugins: [resolvePlugin({ preferBuiltins: true }), commonjsPlugin()],
acornInjectPlugins: [eventualSend(acorn)],
});
Expand Down

0 comments on commit 9043516

Please sign in to comment.