Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/builders/scripts/orchestration/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
*/
export const parseChainHubOpts = async scriptArgs => {
// import dynamically so the modules can work in CoreEval environment
const { parseArgs } = await import('node:util');
const avoidBundling = 'node:util';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose esbuild it bundling node-util when it sees the literal. But the code here shouldn't be concerned with that.

Instead please configure esbuild with the --external option to exclude what shouldn't be bundled.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for raising this.

I started with surgical use of --external, but the list was growing too large for my comfort, and it was fragile.

When digging a little deeper, I see that I can use (await import('node:module')).builtinModules and 'node:*' to catch 'em all.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, now I hit a different hurdle that makes --external fail for a different reason. We need to package the esbuild output with the original @endo/bundle-source implementation, and that chokes on all the modules that esbuild has passed through.

It seems @endo/compartment-mapper hasn't sufficiently implemented externals for this use, but I'll ask @kriskowal if there's a way to make this work.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still digging. I hope to have a solution by tomorrow.

const { parseArgs } = await import(avoidBundling);

/** @type {ParseArgsConfig['options']} */
const parserOpts = {
Expand Down
3 changes: 2 additions & 1 deletion packages/builders/scripts/testing/provokeBOYD.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export const defaultProposalBuilder = async () =>

/** @type {DeployScriptFunction} */
export default async (homeP, endowments) => {
const dspModule = await import('@agoric/deploy-script-support');
const avoidBundling = '@agoric/deploy-script-support';
const dspModule = await import(avoidBundling);
const { makeHelpers } = dspModule;
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval(provokeBOYD.name, defaultProposalBuilder);
Expand Down
3 changes: 2 additions & 1 deletion packages/builders/scripts/testing/publish-test-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ export const defaultProposalBuilder = async () =>
/** @type {DeployScriptFunction} */
export default async (homeP, endowments) => {
// import dynamically so the module can work in CoreEval environment
const dspModule = await import('@agoric/deploy-script-support');
const avoidBundling = '@agoric/deploy-script-support';
const dspModule = await import(avoidBundling);
const { makeHelpers } = dspModule;
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval('publish-test-info', defaultProposalBuilder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ export const defaultProposalBuilder = async () =>
/** @type {DeployScriptFunction} */
export default async (homeP, endowments) => {
// import dynamically so the module can work in CoreEval environment
const dspModule = await import('@agoric/deploy-script-support');
const avoidBundling = '@agoric/deploy-script-support';
const dspModule = await import(avoidBundling);
const { makeHelpers } = dspModule;
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval('recorded-retired', defaultProposalBuilder);
Expand Down
3 changes: 2 additions & 1 deletion packages/builders/scripts/testing/restart-axelar-gmp.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ export const defaultProposalBuilder = async () =>

/** @type {DeployScriptFunction} */
export default async (homeP, endowments) => {
const dspModule = await import('@agoric/deploy-script-support');
const avoidBundling = '@agoric/deploy-script-support';
const dspModule = await import(avoidBundling);
const { makeHelpers } = dspModule;
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval(restartAxelarGmp.name, defaultProposalBuilder);
Expand Down
3 changes: 2 additions & 1 deletion packages/builders/scripts/testing/restart-basic-flows.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ export const defaultProposalBuilder = async () =>
/** @type {DeployScriptFunction} */
export default async (homeP, endowments) => {
// import dynamically so the module can work in CoreEval environment
const dspModule = await import('@agoric/deploy-script-support');
const avoidBundling = '@agoric/deploy-script-support';
const dspModule = await import(avoidBundling);
const { makeHelpers } = dspModule;
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval(restartBasicFlows.name, defaultProposalBuilder);
Expand Down
3 changes: 2 additions & 1 deletion packages/builders/scripts/testing/restart-send-anywhere.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ export const defaultProposalBuilder = async () =>
/** @type {DeployScriptFunction} */
export default async (homeP, endowments) => {
// import dynamically so the module can work in CoreEval environment
const dspModule = await import('@agoric/deploy-script-support');
const avoidBundling = '@agoric/deploy-script-support';
const dspModule = await import(avoidBundling);
const { makeHelpers } = dspModule;
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval(restartSendAnywhere.name, defaultProposalBuilder);
Expand Down
3 changes: 2 additions & 1 deletion packages/builders/scripts/testing/restart-stakeAtom.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ export const defaultProposalBuilder = async () =>
/** @type {DeployScriptFunction} */
export default async (homeP, endowments) => {
// import dynamically so the module can work in CoreEval environment
const dspModule = await import('@agoric/deploy-script-support');
const avoidBundling = '@agoric/deploy-script-support';
const dspModule = await import(avoidBundling);
const { makeHelpers } = dspModule;
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval(restartStakeAtom.name, defaultProposalBuilder);
Expand Down
3 changes: 2 additions & 1 deletion packages/builders/scripts/testing/restart-valueVow.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ export const defaultProposalBuilder = async ({ publishRef, install }) =>
/** @type {DeployScriptFunction} */
export default async (homeP, endowments) => {
// import dynamically so the module can work in CoreEval environment
const dspModule = await import('@agoric/deploy-script-support');
const avoidBundling = '@agoric/deploy-script-support';
const dspModule = await import(avoidBundling);
const { makeHelpers } = dspModule;
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval(restartValueVow.name, defaultProposalBuilder);
Expand Down
3 changes: 2 additions & 1 deletion packages/builders/scripts/testing/start-query-flows.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ export const defaultProposalBuilder = async (
/** @type {DeployScriptFunction} */
export default async (homeP, endowments) => {
// import dynamically so the modules can work in CoreEval environment
const { makeHelpers } = await import('@agoric/deploy-script-support');
const avoidBundling = '@agoric/deploy-script-support';
const { makeHelpers } = await import(avoidBundling);
const { scriptArgs } = endowments;
const opts = parseChainHubOpts(scriptArgs);
const { writeCoreEval } = await makeHelpers(homeP, endowments);
Expand Down
3 changes: 2 additions & 1 deletion packages/builders/scripts/testing/start-valueVow.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ export const defaultProposalBuilder = async ({ publishRef, install }) =>
/** @type {DeployScriptFunction} */
export default async (homeP, endowments) => {
// import dynamically so the module can work in CoreEval environment
const dspModule = await import('@agoric/deploy-script-support');
const avoidBundling = '@agoric/deploy-script-support';
const dspModule = await import(avoidBundling);
const { makeHelpers } = dspModule;
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval('start-valueVow', defaultProposalBuilder);
Expand Down
3 changes: 2 additions & 1 deletion packages/builders/scripts/testing/upgrade-send-anywhere.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ export const defaultProposalBuilder = async ({ publishRef, install }) =>
/** @type {DeployScriptFunction} */
export default async (homeP, endowments) => {
// import dynamically so the module can work in CoreEval environment
const dspModule = await import('@agoric/deploy-script-support');
const avoidBundling = '@agoric/deploy-script-support';
const dspModule = await import(avoidBundling);
const { makeHelpers } = dspModule;
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval(upgradeSendAnywhere.name, defaultProposalBuilder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ export const defaultProposalBuilder = async (
[producedKey, label = producedKey] = [],
) => {
// Dynamic import to avoid inclusion in the proposal bundle.
const { getSpecifier } = await import('@agoric/internal/src/module-utils.js');
const avoidBundling = '@agoric/internal/src/module-utils.js';
const { getSpecifier } = await import(avoidBundling);
const SELF = await getSpecifier(import.meta.url);

// await install('@agoric/governance/src/contractGovernor.js');
Expand All @@ -200,7 +201,8 @@ export const defaultProposalBuilder = async (
export default async (homeP, endowments) => {
const { scriptArgs } = endowments;
// Dynamic import to avoid inclusion in the proposal bundle.
const { makeHelpers } = await import('@agoric/deploy-script-support');
const avoidBundling = '@agoric/deploy-script-support';
const { makeHelpers } = await import(avoidBundling);
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval(startGovernedInstance.name, utils =>
defaultProposalBuilder(utils, scriptArgs),
Expand Down
3 changes: 2 additions & 1 deletion packages/inter-protocol/test/smartWallet/contexts.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export const importBootTestUtils = async (log, bundleCache) => {
bundleCache.validateOrAdd(entrypoint, name),
),
);
const utils = await import('./boot-test-utils.js');
const avoidBundling = './boot-test-utils.js';
const utils = await import(avoidBundling);
const mockPsmBootstrapArgs = () => {
const mock = utils.makeMock(log);
const vats = utils.mockSwingsetVats(mock);
Expand Down
3 changes: 2 additions & 1 deletion packages/portfolio-deploy/src/chain-info.build.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ export default async (homeP, endowments) => {
if (flags.net) {
if (!(flags.peer && flags.peer.length)) throw Error('--peer required');
// only import/use net access if asked with --net
const { execFileSync } = await import('child_process');
const avoidBundling = 'child_process';
const { execFileSync } = await import(avoidBundling);
const { chainName: chainId, rpcAddrs } = await getNetConfig(
flags.net,
fetch,
Expand Down
3 changes: 2 additions & 1 deletion packages/portfolio-deploy/src/usdc-resolve.build.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ export const defaultProposalBuilder = async _utils =>
/** @type {DeployScriptFunction} */
export default async (homeP, endowments) => {
// import dynamically so the module can work in CoreEval environment
const dspModule = await import('@agoric/deploy-script-support');
const avoidBundling = '@agoric/deploy-script-support';
const dspModule = await import(avoidBundling);
const { makeHelpers } = dspModule;
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval('eval-usdc-resolve', defaultProposalBuilder);
Expand Down
3 changes: 2 additions & 1 deletion packages/stat-logger/src/statGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ export async function renderGraph(spec, outputPath, type = 'png') {
// NOTE: If this import expression fails, you need to install the
// peerDependencies.
// Dynamic version of `import * as vega from 'vega';`
const vega = await import('vega');
const avoidBundling = 'vega';
const vega = await import(avoidBundling);

const view = new vega.View(vega.parse(spec, null), {
loader: vega.loader({ baseURL: loadDir }),
Expand Down
3 changes: 2 additions & 1 deletion packages/vat-data/test/absent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ delete globalThis.VatData;

/** @see present.test.js */
test('methods available that throw', async t => {
const { defineKind } = await import('../src/index.js');
const avoidBundling = '../src/index.js';
const { defineKind } = await import(avoidBundling);
t.throws(() => defineKind('someTag', () => {}, {}), {
message: /VatData unavailable/,
});
Expand Down
3 changes: 2 additions & 1 deletion packages/vat-data/test/present.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const mockDefineKind = /** @type {any} */ (harden({}));
globalThis.VatData ||= { defineKind: mockDefineKind };

test('methods available', async t => {
const { defineKind } = await import('../src/index.js');
const avoidBundling = '../src/index.js';
const { defineKind } = await import(avoidBundling);
t.is(defineKind, mockDefineKind);
});
6 changes: 4 additions & 2 deletions packages/vats/src/proposals/terminate-governed-instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ export const defaultProposalBuilder = async (_utils, targetSpecifiers) => {
parseTargets(targetSpecifiers);

// Dynamic import to avoid inclusion in the proposal bundle.
const { getSpecifier } = await import('@agoric/internal/src/module-utils.js');
const avoidBundling = '@agoric/internal/src/module-utils.js';
const { getSpecifier } = await import(avoidBundling);
const SELF = await getSpecifier(import.meta.url);

return harden({
Expand All @@ -233,7 +234,8 @@ export default async (homeP, endowments) => {
parseTargets(scriptArgs, makeUsageError);

// Dynamic import to avoid inclusion in the proposal bundle.
const { makeHelpers } = await import('@agoric/deploy-script-support');
const avoidBundling = '@agoric/deploy-script-support';
const { makeHelpers } = await import(avoidBundling);
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval(terminateGoverned.name, utils =>
defaultProposalBuilder(utils, scriptArgs),
Expand Down