chore: change 'use' and 'utter' to 'need' in import meta detection to adhere to the compartment proposal
MODIFY
packages/ses/README.md
packages/ses/README.md
@@ -419,7 +419,9 @@ A compiled static module record has the following shape:
exports to notifier functions.
A notifier function accepts an update function and registers
to receive updates for the value exported by the other module.
- - `importMeta` is a null-prototype object with keys transferred from `meta` property in the envelope returned by importHook and/or mutated by calling `importMetaHook(importMeta)`
+ - `importMeta` is a null-prototype object with keys transferred from `importMeta`
+ property in the envelope returned by importHook and/or mutated by
+ calling `importMetaHook(moduleSpecifier, importMeta)`
- `liveVar` is a record that maps names exported by this module
to a function that may be called to initialize or update
the corresponding value in another module.

MODIFY
packages/ses/src/module-instance.js
packages/ses/src/module-instance.js
@@ -127,14 +127,14 @@ export const makeModuleInstance = (
compartment,
moduleSpecifier,
staticModuleRecord,
- meta: moduleRecordMeta,
+ importMeta: moduleRecordMeta,
} = moduleRecord;
const {
reexports: exportAlls = [],
__syncModuleProgram__: functorSource,
__fixedExportMap__: fixedExportMap = {},
__liveExportMap__: liveExportMap = {},
- __usesImportMeta__: usesImportMeta = false,
+ __needsImportMeta__: needsImportMeta = false,
} = staticModuleRecord;
const compartmentFields = weakmapGet(privateFields, compartment);
@@ -169,8 +169,8 @@ export const makeModuleInstance = (
if (moduleRecordMeta) {
assign(importMeta, moduleRecordMeta);
}
- if (usesImportMeta && importMetaHook) {
- importMetaHook(importMeta);
+ if (needsImportMeta && importMetaHook) {
+ importMetaHook(moduleSpecifier, importMeta);
}
// {_localName_: [{get, set, notify}]} used to merge all the export updaters.

MODIFY
packages/ses/src/module-load.js
packages/ses/src/module-load.js
@@ -63,7 +63,7 @@ const loadRecord = async (
pendingJobs,
moduleLoads,
errors,
- meta,
+ importMeta,
) => {
const { resolveHook, moduleRecords } = weakmapGet(
compartmentPrivateFields,
@@ -81,7 +81,7 @@ const loadRecord = async (
staticModuleRecord,
moduleSpecifier,
resolvedImports,
- meta,
+ importMeta,
});
// Enqueue jobs to load this module's shallow dependencies.
@@ -183,7 +183,7 @@ const loadWithoutErrorAnnotation = async (
compartment: aliasCompartment = compartment,
specifier: aliasSpecifier = moduleSpecifier,
record: aliasModuleRecord,
- meta,
+ importMeta,
} = staticModuleRecord;
const aliasRecord = await loadRecord(
@@ -195,7 +195,7 @@ const loadWithoutErrorAnnotation = async (
pendingJobs,
moduleLoads,
errors,
- meta,
+ importMeta,
);
mapSet(moduleRecords, moduleSpecifier, aliasRecord);
return aliasRecord;

MODIFY
packages/ses/test/node.js
packages/ses/test/node.js
@@ -63,9 +63,9 @@ export const makeLocator = root => {
};
};
-const wrapImporterWithMeta = (importer, meta) => async specifier => {
+const wrapImporterWithMeta = (importer, importMeta) => async specifier => {
const moduleRecord = await importer(specifier);
- return { record: moduleRecord, meta };
+ return { record: moduleRecord, importMeta };
};
// makeNodeImporter conveniently curries makeImporter with a Node.js style

MODIFY
packages/ses/test/test-import.js
packages/ses/test/test-import.js
@@ -602,7 +602,7 @@ test('importMetaHook', async t => {
name: 'https://example.com',
resolveHook: resolveNode,
importHook: makeImportHook('https://example.com'),
- importMetaHook: meta => {
+ importMetaHook: (_moduleSpecifier, meta) => {
meta.url = 'https://example.com/index.js';
},
},
@@ -632,7 +632,7 @@ test('importMetaHook and meta from record', async t => {
importHook: makeImportHook('https://example.com', {
meta: { url: 'https://example.com/index.js' },
}),
- importMetaHook: meta => {
+ importMetaHook: (_moduleSpecifier, meta) => {
meta.url += '?foo';
meta.isStillMutableHopefully = 1;
},

MODIFY
packages/static-module-record/src/babelPlugin.js
packages/static-module-record/src/babelPlugin.js
@@ -300,7 +300,7 @@ function makeModulePlugins(options) {
path.node.meta.name === 'import' &&
path.node.property.name === 'meta'
) {
- importMeta.uttered = true;
+ importMeta.present = true;
path.replaceWithMultiple([
replace(path.node, hiddenIdentifier(h.HIDDEN_META)),
]);

MODIFY
packages/static-module-record/src/static-module-record.js
packages/static-module-record/src/static-module-record.js
@@ -51,7 +51,7 @@ export function StaticModuleRecord(source, url) {
liveExportMap,
fixedExportMap,
exportAlls,
- importMetaUttered,
+ needsImportMeta,
} = analyzeModule({ string: source, url });
this.imports = freeze([...keys(imports)].sort());
this.exports = freeze(
@@ -61,6 +61,6 @@ export function StaticModuleRecord(source, url) {
this.__syncModuleProgram__ = functorSource;
this.__liveExportMap__ = liveExportMap;
this.__fixedExportMap__ = fixedExportMap;
- this.__usesImportMeta__ = importMetaUttered;
+ this.__needsImportMeta__ = needsImportMeta;
freeze(this);
}

MODIFY
packages/static-module-record/src/transform-analyze.js
packages/static-module-record/src/transform-analyze.js
@@ -26,7 +26,7 @@ const makeCreateStaticRecord = transformSource =>
importSources: Object.create(null),
importDecls: [],
// enables passing import.meta usage hints up.
- importMeta: { uttered: false },
+ importMeta: { present: false },
};
if (moduleSource.startsWith('#!')) {
// Comment out the shebang lines.
@@ -90,7 +90,7 @@ const makeCreateStaticRecord = transformSource =>
imports: freeze(sourceOptions.imports),
liveExportMap: freeze(sourceOptions.liveExportMap),
fixedExportMap: freeze(sourceOptions.fixedExportMap),
- importMetaUttered: sourceOptions.importMeta.uttered,
+ needsImportMeta: sourceOptions.importMeta.present,
functorSource,
});
return moduleAnalysis;

MODIFY
packages/static-module-record/test/benchmark-babel-plugin.js
packages/static-module-record/test/benchmark-babel-plugin.js
@@ -33,7 +33,7 @@ const freshOptions = () => {
hoistedDecls: [],
importSources: Object.create(null),
importDecls: [],
- importMeta: { uttered: false },
+ importMeta: { present: false },
};
};

MODIFY
packages/static-module-record/test/fixtures/large.js
packages/static-module-record/test/fixtures/large.js
@@ -338,7 +338,7 @@ function makeModulePlugins(options) {
path.node.property.name === 'meta'
) {
if (doAnalyze) {
- importMeta.uttered = true;
+ importMeta.present = true;
}
if (doTransform) {
console.error('at least I tried')

MODIFY
packages/static-module-record/test/test-static-module-record.js
packages/static-module-record/test/test-static-module-record.js
@@ -570,13 +570,13 @@ test('import meta in export', t => {
});
t.is(namespace.a, 'ok file://meta.url');
});
-test('import meta member uttered', t => {
+test('import meta member present', t => {
const record = new StaticModuleRecord(`const a = import.meta.url`);
- t.is(record.__usesImportMeta__, true);
+ t.is(record.__needsImportMeta__, true);
});
-test('import meta uttered', t => {
+test('import meta present', t => {
const record = new StaticModuleRecord(`const a = import.meta`);
- t.is(record.__usesImportMeta__, true);
+ t.is(record.__needsImportMeta__, true);
});
test('export names', t => {

MODIFY
yarn.lock
yarn.lock
@@ -9639,13 +9639,6 @@ pkg-dir@^4.2.0:
dependencies:
find-up "^4.0.0"
-pkg-up@^2.0.0:
- version "2.0.0"
- resolved "https://registry.yarnpkg.com/pkg-up/-/pkg-up-2.0.0.tgz#c819ac728059a461cab1c3889a2be3c49a004d7f"
- integrity sha1-yBmscoBZpGHKscOImivjxJoATX8=
- dependencies:
- find-up "^2.1.0"
-
platform@^1.3.3:
version "1.3.6"
resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.6.tgz#48b4ce983164b209c2d45a107adb31f473a6e7a7"

chore: change 'use' and 'utter' to 'need' in import meta detection to adhere to the compartment proposal