diff --git a/packages/bundle-source/src/is-entrypoint.js b/packages/bundle-source/src/is-entrypoint.js index ce72b4ac26..58790eede1 100644 --- a/packages/bundle-source/src/is-entrypoint.js +++ b/packages/bundle-source/src/is-entrypoint.js @@ -3,7 +3,14 @@ import url from 'url'; import process from 'process'; import fs from 'fs'; +// Agoric still uses Endo dependencies under an emulation of ESM we call RESM +// because it is invoked with `node -r esm`. +// RESM does not support ?? nor ?. operators, so we must avoid them expressly. +// TODO remove when https://github.com/Agoric/agoric-sdk/issues/8671 +const favor = (primary, secondary) => + primary === undefined ? secondary : primary; + // FIXME: Should maybe be exported by '@endo/something'? export const isEntrypoint = href => String(href) === - url.pathToFileURL(fs.realpathSync(process.argv[1]) ?? '/').href; + url.pathToFileURL(fs.realpathSync(favor(process.argv[1]), '/')).href;