diff --git a/packages/agoric-cli/lib/deploy.js b/packages/agoric-cli/lib/deploy.js index 7bcc553d437a..8398cf755252 100644 --- a/packages/agoric-cli/lib/deploy.js +++ b/packages/agoric-cli/lib/deploy.js @@ -1,13 +1,17 @@ /* global process setTimeout setInterval clearInterval */ /* eslint-disable no-await-in-loop */ + import { E, makeCapTP } from '@agoric/captp'; import { makePromiseKit } from '@agoric/promise-kit'; import bundleSource from '@agoric/bundle-source'; import path from 'path'; import inquirer from 'inquirer'; +import createRequire from 'esm'; import { getAccessToken } from '@agoric/access-token'; +const require = createRequire({}); + // note: CapTP has its own HandledPromise instantiation, and the contract // must use the same one that CapTP uses. We achieve this by not bundling // captp, and doing a (non-isolated) dynamic import of the deploy script @@ -220,7 +224,11 @@ export { bootPlugin } from ${JSON.stringify(absPath)}; } // use a dynamic import to load the deploy script, it is unconfined - const mainNS = await import(pathResolve(moduleFile)); + // eslint-disable-next-line import/no-dynamic-require + const mainNS = require(moduleFile); + // TODO Node.js ESM support if package.json of template says "type": + // "module": + // const mainNS = await import(pathResolve(moduleFile)); const main = mainNS.default; if (typeof main !== 'function') { console.error( diff --git a/packages/agoric-cli/lib/entrypoint.js b/packages/agoric-cli/lib/entrypoint.js index b6e6200c4b90..30c6cb015aa5 100755 --- a/packages/agoric-cli/lib/entrypoint.js +++ b/packages/agoric-cli/lib/entrypoint.js @@ -1,8 +1,9 @@ #!/usr/bin/env -S node /* global process */ -// TODO Remove babel-standalone preinitialization +// TODO Remove babel-standalone and esm preinitialization // https://github.com/endojs/endo/issues/768 +import 'esm'; import '@agoric/babel-standalone'; import '@agoric/install-ses'; diff --git a/packages/agoric-cli/package.json b/packages/agoric-cli/package.json index a1270c7fda9b..c76a7e34fdfc 100644 --- a/packages/agoric-cli/package.json +++ b/packages/agoric-cli/package.json @@ -39,6 +39,7 @@ "chalk": "^2.4.2", "commander": "^5.0.0", "deterministic-json": "^1.0.5", + "esm": "agoric-labs/esm#Agoric-built", "inquirer": "^6.3.1", "opener": "^1.5.2", "ws": "^7.2.0"