Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

standards-compliant import.meta.resolve #10985

Merged
merged 7 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 7 additions & 7 deletions a3p-integration/proposals/z:acceptance/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ __metadata:
"@endo/marshal": "npm:^1.6.3"
"@endo/nat": "npm:^5.0.14"
"@endo/promise-kit": "npm:^1.1.9"
import-meta-resolve: "npm:^2.2.1"
import-meta-resolve: "npm:^4.1.0"
languageName: node
linkType: soft

Expand Down Expand Up @@ -331,7 +331,7 @@ __metadata:
ansi-styles: "npm:^6.2.1"
anylogger: "npm:^0.21.0"
better-sqlite3: "npm:^9.1.1"
import-meta-resolve: "npm:^2.2.1"
import-meta-resolve: "npm:^4.1.0"
microtime: "npm:^3.1.0"
semver: "npm:^6.3.0"
tmp: "npm:^0.2.1"
Expand Down Expand Up @@ -420,7 +420,7 @@ __metadata:
"@endo/pass-style": "npm:^1.4.8"
"@endo/patterns": "npm:^1.4.8"
"@endo/promise-kit": "npm:^1.1.9"
import-meta-resolve: "npm:^2.2.1"
import-meta-resolve: "npm:^4.1.0"
jessie.js: "npm:^0.3.4"
languageName: node
linkType: soft
Expand Down Expand Up @@ -3778,10 +3778,10 @@ __metadata:
languageName: node
linkType: hard

"import-meta-resolve@npm:^2.2.1":
version: 2.2.2
resolution: "import-meta-resolve@npm:2.2.2"
checksum: 10c0/80873aebf0d2a66e824e278fb6cbb16a6660f86df49b367404e5de80928720ecb44f643243b46dc5c5fae506abb666ef54d6f281b45ee0f1034951acb2261eb5
"import-meta-resolve@npm:^4.1.0":
version: 4.1.0
resolution: "import-meta-resolve@npm:4.1.0"
checksum: 10c0/42f3284b0460635ddf105c4ad99c6716099c3ce76702602290ad5cbbcd295700cbc04e4bdf47bacf9e3f1a4cec2e1ff887dabc20458bef398f9de22ddff45ef5
languageName: node
linkType: hard

Expand Down
14 changes: 7 additions & 7 deletions multichain-testing/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ __metadata:
"@endo/marshal": "npm:^1.6.3"
"@endo/nat": "npm:^5.0.14"
"@endo/promise-kit": "npm:^1.1.9"
import-meta-resolve: "npm:^2.2.1"
import-meta-resolve: "npm:^4.1.0"
languageName: node
linkType: soft

Expand Down Expand Up @@ -370,7 +370,7 @@ __metadata:
ansi-styles: "npm:^6.2.1"
anylogger: "npm:^0.21.0"
better-sqlite3: "npm:^9.1.1"
import-meta-resolve: "npm:^2.2.1"
import-meta-resolve: "npm:^4.1.0"
microtime: "npm:^3.1.0"
semver: "npm:^6.3.0"
tmp: "npm:^0.2.1"
Expand Down Expand Up @@ -443,7 +443,7 @@ __metadata:
"@endo/pass-style": "npm:^1.4.8"
"@endo/patterns": "npm:^1.4.8"
"@endo/promise-kit": "npm:^1.1.9"
import-meta-resolve: "npm:^2.2.1"
import-meta-resolve: "npm:^4.1.0"
jessie.js: "npm:^0.3.4"
languageName: node
linkType: soft
Expand Down Expand Up @@ -3540,10 +3540,10 @@ __metadata:
languageName: node
linkType: hard

"import-meta-resolve@npm:^2.2.1":
version: 2.2.2
resolution: "import-meta-resolve@npm:2.2.2"
checksum: 10c0/80873aebf0d2a66e824e278fb6cbb16a6660f86df49b367404e5de80928720ecb44f643243b46dc5c5fae506abb666ef54d6f281b45ee0f1034951acb2261eb5
"import-meta-resolve@npm:^4.1.0":
version: 4.1.0
resolution: "import-meta-resolve@npm:4.1.0"
checksum: 10c0/42f3284b0460635ddf105c4ad99c6716099c3ce76702602290ad5cbbcd295700cbc04e4bdf47bacf9e3f1a4cec2e1ff887dabc20458bef398f9de22ddff45ef5
languageName: node
linkType: hard

Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"ansi-styles": "^6.2.1",
"anylogger": "^0.21.0",
"better-sqlite3": "^9.1.1",
"import-meta-resolve": "^2.2.1",
"import-meta-resolve": "^4.1.0",
"microtime": "^3.1.0",
"semver": "^6.3.0",
"tmp": "^0.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/boot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"@endo/marshal": "^1.6.3",
"@endo/promise-kit": "^1.1.9",
"@endo/stream": "^1.2.9",
"import-meta-resolve": "^2.2.1"
"import-meta-resolve": "^4.1.0"
},
"devDependencies": {
"@agoric/deploy-script-support": "^0.10.3",
Expand Down
7 changes: 3 additions & 4 deletions packages/boot/test/configs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ import { mustMatch } from '@agoric/store';
import { loadSwingsetConfigFile, shape as ssShape } from '@agoric/swingset-vat';
import { provideBundleCache } from '@agoric/swingset-vat/tools/bundleTool.js';

const importConfig = configName =>
importMetaResolve(`@agoric/vm-config/${configName}`, import.meta.url).then(
u => new URL(u).pathname,
);
const importConfig = async configName =>
new URL(importMetaResolve(`@agoric/vm-config/${configName}`, import.meta.url))
.pathname;

const test =
/** @type {import('ava').TestFn<Awaited<ReturnType<typeof makeTestContext>>>}} */ (
Expand Down
4 changes: 2 additions & 2 deletions packages/boot/test/upgrading/upgrade-contracts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { buildVatController } from '@agoric/swingset-vat';
const test = anyTest;

const bfile = name => new URL(name, import.meta.url).pathname;
const importSpec = spec =>
importMetaResolve(spec, import.meta.url).then(u => new URL(u).pathname);
const importSpec = async spec =>
new URL(importMetaResolve(spec, import.meta.url)).pathname;
Copy link
Member

Choose a reason for hiding this comment

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

Not necessary to fix everything in one pass, but notably, this is an opportunity to replace .pathname with fileURLToPath as that’s more robust across platforms or checkout directories with spaces (.pathname will have %20 instead of the obligate space).


test('upgrade mintHolder', async t => {
/** @type {SwingSetConfig} */
Expand Down
4 changes: 2 additions & 2 deletions packages/boot/test/upgrading/upgrade-vats.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { matchAmount, matchIter, matchRef } from '../../tools/supports.js';
import type { buildRootObject as buildTestMintVat } from './vat-mint.js';

const bfile = name => new URL(name, import.meta.url).pathname;
const importSpec = spec =>
importMetaResolve(spec, import.meta.url).then(u => new URL(u).pathname);
const importSpec = async spec =>
new URL(importMetaResolve(spec, import.meta.url)).pathname;

const makeCallOutbound = t => (srcID, obj) => {
t.log(`callOutbound(${srcID}, ${obj})`);
Expand Down
3 changes: 2 additions & 1 deletion packages/boot/tools/authorityViz.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ const run = async () => {
stdout: process.stdout,
fsp,
meta: {
resolve: metaResolve.resolve,
resolve: async (specifier, parent) =>
metaResolve.resolve(specifier, parent),
url: import.meta.url,
load: specifier => import(specifier),
},
Expand Down
11 changes: 5 additions & 6 deletions packages/boot/tools/supports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,8 @@ export const getNodeTestVaultsConfig = async ({
defaultManagerType = 'local' as ManagerType,
discriminator = '',
}) => {
const fullPath = await importMetaResolve(specifier, import.meta.url).then(
u => new URL(u).pathname,
);
const fullPath = new URL(importMetaResolve(specifier, import.meta.url))
.pathname;
const config: SwingSetConfig & { coreProposals?: any[] } = NonNullish(
await loadSwingsetConfigFile(fullPath),
);
Expand Down Expand Up @@ -163,13 +162,13 @@ interface Powers {
fs: typeof import('node:fs/promises');
}

const importSpec = async spec =>
new URL(importMetaResolve(spec, import.meta.url)).pathname;

export const makeProposalExtractor = ({ childProcess, fs }: Powers) => {
const getPkgPath = (pkg, fileName = '') =>
new URL(`../../${pkg}/${fileName}`, import.meta.url).pathname;

const importSpec = spec =>
importMetaResolve(spec, import.meta.url).then(u => new URL(u).pathname);

const runPackageScript = (
outputDir: string,
scriptPath: string,
Expand Down
2 changes: 1 addition & 1 deletion packages/builders/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@endo/patterns": "^1.4.8",
"@endo/promise-kit": "^1.1.9",
"@endo/stream": "^1.2.9",
"import-meta-resolve": "^2.2.1"
"import-meta-resolve": "^4.1.0"
},
"devDependencies": {
"@endo/errors": "^1.2.9",
Expand Down
5 changes: 2 additions & 3 deletions packages/builders/test/inter-proposals.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ const test = anyTest;
const makeTestContext = t => {
/** @param {string} specifier */
const loadConfig = async specifier => {
const fullPath = await importMetaResolve(specifier, import.meta.url).then(
u => new URL(u).pathname,
);
const fullPath = new URL(importMetaResolve(specifier, import.meta.url))
.pathname;
t.is(typeof fullPath, 'string');
const txt = await ambientFs.promises.readFile(fullPath, 'utf-8');
t.is(typeof txt, 'string');
Expand Down
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@opentelemetry/sdk-metrics": "~1.30.1",
"anylogger": "^0.21.0",
"deterministic-json": "^1.0.5",
"import-meta-resolve": "^2.2.1",
"import-meta-resolve": "^4.1.0",
"ses": "^1.11.0",
"tmp": "^0.2.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/src/chain-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ export const makeLaunchChain = (
bootMsg: makeInitMsg(initAction),
};
const getVatConfig = async () => {
const href = await importMetaResolve(
const href = importMetaResolve(
env.CHAIN_BOOTSTRAP_VAT_CONFIG ||
argv.bootMsg.params.bootstrap_vat_config,
import.meta.url,
Expand Down
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/src/sim-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export async function connectToFakeChain(basedir, GCI, delay, inbound) {
};

const getVatConfig = async () => {
const href = await importMetaResolve(
const href = importMetaResolve(
env.CHAIN_BOOTSTRAP_VAT_CONFIG ||
argv.bootMsg.params.bootstrap_vat_config,
import.meta.url,
Expand Down
2 changes: 1 addition & 1 deletion packages/deploy-script-support/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@agoric/vats": "^0.15.1",
"@endo/init": "^1.1.8",
"ava": "^5.3.0",
"import-meta-resolve": "^2.2.1"
"import-meta-resolve": "^4.1.0"
},
"files": [
"src",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test('install', async t => {
const board = makeFakeBoard();
const install = makeInstall(bundleSource, zoe, installationManager, board);

const resolvedUrl = await importMetaResolve(
const resolvedUrl = importMetaResolve(
'@agoric/zoe/src/contracts/automaticRefund.js',
import.meta.url,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test('offer', async t => {
};
const zoe = makeZoeForTest();

const bundleUrl = await importMetaResolve(
const bundleUrl = importMetaResolve(
'@agoric/zoe/src/contracts/automaticRefund.js',
import.meta.url,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test('startInstance', async t => {
const zoe = makeZoeForTest();

const bundleUrl = new URL(
await importMetaResolve(
importMetaResolve(
'@agoric/zoe/src/contracts/automaticRefund.js',
import.meta.url,
),
Expand Down
2 changes: 1 addition & 1 deletion packages/governance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@endo/marshal": "^1.6.3",
"@endo/nat": "^5.0.14",
"@endo/promise-kit": "^1.1.9",
"import-meta-resolve": "^2.2.1"
"import-meta-resolve": "^4.1.0"
},
"devDependencies": {
"@agoric/swingset-vat": "^0.32.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const contractGovernorRoot = '../../src/contractGovernor.js';
const committeeRoot = '../../src/committee.js';

const makeBundle = async sourceRoot => {
const url = await importMetaResolve(sourceRoot, import.meta.url);
const url = importMetaResolve(sourceRoot, import.meta.url);
const path = new URL(url).pathname;
const contractBundle = await bundleSource(path);
return contractBundle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { MALLEABLE_NUMBER } from '../swingsetTests/contractGovernor/governedCont
*/

const makeBundle = async sourceRoot => {
const url = await importMetaResolve(sourceRoot, import.meta.url);
const url = importMetaResolve(sourceRoot, import.meta.url);
const path = new URL(url).pathname;
const contractBundle = await bundleSource(path);
return contractBundle;
Expand Down
2 changes: 1 addition & 1 deletion packages/governance/tools/puppetGovernance.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CONTRACT_ELECTORATE, ParamTypes } from '../src/index.js';
*/

const makeBundle = async sourceRoot => {
const url = await importMetaResolve(sourceRoot, import.meta.url);
const url = importMetaResolve(sourceRoot, import.meta.url);
const path = new URL(url).pathname;
const contractBundle = await bundleSource(path);
return contractBundle;
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"ava": "^5.3.0",
"c8": "^10.1.2",
"deep-object-diff": "^1.1.9",
"import-meta-resolve": "^2.2.1"
"import-meta-resolve": "^4.1.0"
},
"files": [
"scripts",
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/test/auction/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { resolve as importMetaResolve } from 'import-meta-resolve';
/** @param {ZoeService} zoe */
export const setUpInstallations = async zoe => {
const autoRefund = '@agoric/zoe/src/contracts/automaticRefund.js';
const autoRefundUrl = await importMetaResolve(autoRefund, import.meta.url);
const autoRefundUrl = importMetaResolve(autoRefund, import.meta.url);
const autoRefundPath = new URL(autoRefundUrl).pathname;

const bundleCache = await unsafeMakeBundleCache('./bundles/'); // package-relative
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { faV1BundleName } from './bootstrap-fluxAggregator-service-upgrade.js';

// so paths can be expresssed relative to this file and made absolute
const bfile = name => new URL(name, import.meta.url).pathname;
const resolvePathname = spec =>
new URL(importMetaResolve(spec, import.meta.url)).pathname;

test('fluxAggregator service upgrade', async t => {
/** @type {SwingSetConfig} */
Expand All @@ -21,36 +23,25 @@ test('fluxAggregator service upgrade', async t => {
sourceSpec: bfile('bootstrap-fluxAggregator-service-upgrade.js'),
},
zoe: {
sourceSpec: await importMetaResolve(
'@agoric/vats/src/vat-zoe.js',
import.meta.url,
).then(href => new URL(href).pathname),
sourceSpec: resolvePathname('@agoric/vats/src/vat-zoe.js'),
},
},
bundles: {
zcf: {
sourceSpec: await importMetaResolve(
'@agoric/zoe/src/contractFacet/vatRoot.js',
import.meta.url,
).then(href => new URL(href).pathname),
sourceSpec: resolvePathname('@agoric/zoe/src/contractFacet/vatRoot.js'),
},
committee: {
sourceSpec: await importMetaResolve(
'@agoric/governance/src/committee.js',
import.meta.url,
).then(href => new URL(href).pathname),
sourceSpec: resolvePathname('@agoric/governance/src/committee.js'),
},
puppetContractGovernor: {
sourceSpec: await importMetaResolve(
sourceSpec: resolvePathname(
'@agoric/governance/tools/puppetContractGovernor.js',
import.meta.url,
).then(href => new URL(href).pathname),
),
},
[faV1BundleName]: {
sourceSpec: await importMetaResolve(
sourceSpec: resolvePathname(
'@agoric/inter-protocol/src/price/fluxAggregatorContract.js',
import.meta.url,
).then(href => new URL(href).pathname),
),
},
},
};
Expand Down
Loading
Loading