fix: rename meta to importMeta, fix detection to detect import.meta not import.meta.something
MODIFY
packages/compartment-mapper/src/bundle.js
packages/compartment-mapper/src/bundle.js
@@ -332,7 +332,7 @@ ${importsCellSetter(__liveExportMap__, index)}\
onceVar: {
${importsCellSetter(__fixedExportMap__, index)}\
},
- meta: {
+ importMeta: {
url: '${packageLocation}'\
},
});

MODIFY
packages/ses/README.md
packages/ses/README.md
@@ -412,13 +412,14 @@ A compiled static module record has the following shape:
an initialization record and initializes the module.
This property distinguishes this type of module record.
The name implies a future record type that supports top-level await.
- - An initialization record has the properties `imports`, `liveVar`, and
+ - An initialization record has the properties `imports`, `liveVar`, `importMeta` and
`onceVar`.
- `imports` is a function that accepts a map from partial import
module specifiers to maps from names that the corresponding module
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)`
- `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
@@ -165,12 +165,12 @@ export const makeModuleInstance = (
// both initialize and update live bindings.
const liveVar = create(null);
- const meta = create(null);
+ const importMeta = create(null);
if (moduleRecordMeta) {
- assign(meta, moduleRecordMeta);
+ assign(importMeta, moduleRecordMeta);
}
if (usesImportMeta && importMetaHook) {
- importMetaHook(meta);
+ importMetaHook(importMeta);
}
// {_localName_: [{get, set, notify}]} used to merge all the export updaters.
@@ -453,7 +453,7 @@ export const makeModuleInstance = (
imports: freeze(imports),
onceVar: freeze(onceVar),
liveVar: freeze(liveVar),
- meta,
+ importMeta,
}),
);
} catch (e) {

MODIFY
packages/ses/src/module-load.js
packages/ses/src/module-load.js
@@ -321,7 +321,7 @@ export const load = async (
`Failed to load module ${q(moduleSpecifier)} in package ${q(
compartmentName,
)} (${errors.length} underlying failures: ${arrayJoin(
- arrayMap(errors, error => error.stack),
+ arrayMap(errors, error => error.message),
', ',
)}`,
);

MODIFY
packages/static-module-record/DESIGN.md
packages/static-module-record/DESIGN.md
@@ -19,6 +19,7 @@ moduleFunctor({
imports(importedVariableUpdaters) { /* ... */ },
liveVar: exportedVariableUpdaters,
onceVar: exportedConstantEmitters,
+ importMeta: Object.create(null)
});
```
@@ -85,6 +86,7 @@ line numbers.
imports: $h_imports,
liveVar: $h_live,
onceVar: $h_once,
+ importMeta: $h_import_meta,
}) => {
let foo, bar, fizz, buzz, colour;
$h_imports(

MODIFY
packages/static-module-record/src/babelPlugin.js
packages/static-module-record/src/babelPlugin.js
@@ -47,7 +47,7 @@ function makeModulePlugins(options) {
importDecls,
importSources,
liveExportMap,
- importMetaProperties,
+ importMeta,
} = options;
if (sourceType !== 'module') {
@@ -311,9 +311,13 @@ function makeModulePlugins(options) {
const moduleVisitor = (doAnalyze, doTransform) => ({
MetaProperty(path) {
- if (path.node.meta.name === 'import') {
- if (doAnalyze && path.parentPath.isMemberExpression()) {
- importMetaProperties.add(path.parentPath.node.property.name);
+ if (
+ path.node.meta &&
+ path.node.meta.name === 'import' &&
+ path.node.property.name === 'meta'
+ ) {
+ if (doAnalyze) {
+ importMeta.uttered = true;
}
if (doTransform) {
path.replaceWithMultiple([

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,
- importMetaProperties,
+ importMetaUttered,
} = analyzeModule({ string: source, url });
this.imports = freeze([...keys(imports)].sort());
this.exports = freeze(
@@ -61,8 +61,6 @@ export function StaticModuleRecord(source, url) {
this.__syncModuleProgram__ = functorSource;
this.__liveExportMap__ = liveExportMap;
this.__fixedExportMap__ = fixedExportMap;
- this.__usesImportMeta__ = importMetaProperties.length > 0;
- // useful for knowing if resolve or any other expensive features are used
- this.__usesImportMetaProperties__ = importMetaProperties;
+ this.__usesImportMeta__ = importMetaUttered;
freeze(this);
}

MODIFY
packages/static-module-record/src/transform-analyze.js
packages/static-module-record/src/transform-analyze.js
@@ -65,7 +65,7 @@ const makeCreateStaticRecord = transformSource =>
importSources: Object.create(null),
importDecls: [],
// enables passing import.meta usage hints up.
- importMetaProperties: new Set(),
+ importMeta: { uttered: false },
};
if (moduleSource.startsWith('#!')) {
// Comment out the shebang lines.
@@ -114,7 +114,7 @@ const makeCreateStaticRecord = transformSource =>
imports: ${h.HIDDEN_IMPORTS}, \
liveVar: ${h.HIDDEN_LIVE}, \
onceVar: ${h.HIDDEN_ONCE}, \
- meta: ${h.HIDDEN_META}, \
+ importMeta: ${h.HIDDEN_META}, \
}) => { \
${preamble} \
${scriptSource}
@@ -129,9 +129,7 @@ const makeCreateStaticRecord = transformSource =>
imports: freeze(sourceOptions.imports),
liveExportMap: freeze(sourceOptions.liveExportMap),
fixedExportMap: freeze(sourceOptions.fixedExportMap),
- importMetaProperties: freeze(
- Array.from(sourceOptions.importMetaProperties),
- ),
+ importMetaUttered: sourceOptions.importMeta.uttered,
functorSource,
});
return moduleAnalysis;

MODIFY
packages/static-module-record/test/test-static-module-record.js
packages/static-module-record/test/test-static-module-record.js
@@ -152,7 +152,7 @@ function initialize(t, source, options = {}) {
imports: updateImports,
liveVar: liveUpdaters,
onceVar: onceUpdaters,
- meta: { url: 'file://meta.url' },
+ importMeta: { url: 'file://meta.url' },
});
return { record, namespace, log, updaters };
@@ -568,6 +568,14 @@ test.failing('import meta in export', t => {
});
t.is(namespace.result, 'ok file://meta.url');
});
+test('import meta member uttered', t => {
+ const record = new StaticModuleRecord(`const a = import.meta.url`);
+ t.is(record.__usesImportMeta__, true);
+});
+test('import meta uttered', t => {
+ const record = new StaticModuleRecord(`const a = import.meta`);
+ t.is(record.__usesImportMeta__, true);
+});
test('export names', t => {
const { namespace } = initialize(

fix: rename meta to importMeta, fix detection to detect import.meta not import.meta.something