fix(moduleInstance): evaluate in source code order
Closes
MODIFY
package-lock.json
package-lock.json
}
},
"@agoric/transform-module": {
- "version": "0.1.20",
- "resolved": "https://registry.npmjs.org/@agoric/transform-module/-/transform-module-0.1.20.tgz",
- "integrity": "sha512-Lda1qdoqZZvSJSjjupJmmLyx8F8cskCZ3LYc/NxcX67c4R7QV9LKjXEDKP9QpaG3ZimpCOd7GsZ8FrPpwLnn4w==",
+ "version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/@agoric/transform-module/-/transform-module-0.2.0.tgz",
+ "integrity": "sha512-8OsnjDWkQgh+JIM9qFxDQLbNop0uEEVd8+qZn5V7feghJqeGCglNWInIo5fzSDTl8WoeVZmY6+Ao9oae0cDrTA==",
"dev": true,
"requires": {
"@agoric/evaluate": "^2.1.3",
"esm": "^3.2.5",
"rollup": "^1.17.0",
"rollup-plugin-node-resolve": "^5.2.0"
- },
- "dependencies": {
- "@agoric/default-evaluate-options": {
- "version": "0.2.7",
- "resolved": "https://registry.npmjs.org/@agoric/default-evaluate-options/-/default-evaluate-options-0.2.7.tgz",
- "integrity": "sha512-g/nlyjibuju9CxeRfkULDMygBGKupwFLKvngtAzCsSycBkCBUHGWbN+AVUOPS80j3P+R3yhP6P6FIoVxjRae0g==",
- "dev": true,
- "requires": {
- "@agoric/babel-parser": "^7.6.4",
- "@agoric/eventual-send": "^0.4.4",
- "@agoric/transform-eventual-send": "^1.0.3",
- "@babel/generator": "^7.6.4",
- "esm": "^3.2.5"
- }
- },
- "@agoric/evaluate": {
- "version": "2.1.3",
- "resolved": "https://registry.npmjs.org/@agoric/evaluate/-/evaluate-2.1.3.tgz",
- "integrity": "sha512-UcJTZX4xINir38pkZxMjI1T2QFOMlHyqXekMnZ8NPRbcVaVSMnDbXhs5DnmXTpgti+0LnRRt9+xlesPohMU+2Q==",
- "dev": true,
- "requires": {
- "@agoric/default-evaluate-options": "^0.2.7",
- "esm": "^3.2.5"
- }
- },
- "@agoric/eventual-send": {
- "version": "0.4.5",
- "resolved": "https://registry.npmjs.org/@agoric/eventual-send/-/eventual-send-0.4.5.tgz",
- "integrity": "sha512-d4jngAU8LWmntZ3PXcFoOygC/tqHOl+JlA318LXuxK1/3/oU5UfNoYboa0Bm8xms8KEtcKFtPpcD5EgGzXO1NQ==",
- "dev": true
- },
- "@babel/generator": {
- "version": "7.7.2",
- "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.7.2.tgz",
- "integrity": "sha512-WthSArvAjYLz4TcbKOi88me+KmDJdKSlfwwN8CnUYn9jBkzhq0ZEPuBfkAWIvjJ3AdEV1Cf/+eSQTnp3IDJKlQ==",
- "dev": true,
- "requires": {
- "@babel/types": "^7.7.2",
- "jsesc": "^2.5.1",
- "lodash": "^4.17.13",
- "source-map": "^0.5.0"
- }
- },
- "@babel/types": {
- "version": "7.7.2",
- "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.7.2.tgz",
- "integrity": "sha512-YTf6PXoh3+eZgRCBzzP25Bugd2ngmpQVrk7kXX0i5N9BO7TFBtIgZYs7WtxtOGs8e6A4ZI7ECkbBCEHeXocvOA==",
- "dev": true,
- "requires": {
- "esutils": "^2.0.2",
- "lodash": "^4.17.13",
- "to-fast-properties": "^2.0.0"
- }
- }
}
},
"@babel/code-frame": {
}
},
"rollup": {
- "version": "1.27.3",
- "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.27.3.tgz",
- "integrity": "sha512-79AEh4m5NPCz97GTuIoXpSFIMPyk2AiqVQp040baSRPXk/I4YMGt5/CR9GX5oEYEkxwBZoWLheaS1/w/FidfJw==",
+ "version": "1.27.4",
+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.27.4.tgz",
+ "integrity": "sha512-UaGNOIax/Ixfd92CAAanUilx2RSkkwEfC1lCTw1eL5Re6NURWgX66ARZt5+3px4kYnpSwzyOot4r18c2b+QgJQ==",
"dev": true,
"requires": {
"@types/estree": "*",

MODIFY
package.json
package.json
},
"devDependencies": {
"@agoric/evaluate": "^2.1.3",
- "@agoric/transform-module": "^0.1.20",
+ "@agoric/transform-module": "^0.2.0",
"@babel/core": "^7.7.2",
"eslint": "^6.1.0",
"eslint-config-airbnb-base": "^14.0.0",

MODIFY
src/moduleInstance.js
src/moduleInstance.js
@@ -205,7 +205,7 @@ export function makeModuleInstance(
// The updateRecord must conform to linkageRecord.imports
// updateRecord = Map<specifier, importUpdaters>
// importUpdaters = Map<importName, [update(newValue)*]>
- async function imports(updateRecord, exportAlls) {
+ async function imports(updateRecord) {
// By the time imports is called, the importNS should already be
// initialized with module instances that satisfy
// linkageRecord.imports.
@@ -215,13 +215,13 @@ export function makeModuleInstance(
// export * cannot export default or '*'.
const candidateAll = create(null);
candidateAll.default = false;
- for (const [specifier, moduleId] of entries(linkageRecord.moduleIds)) {
+ for (const [specifier, importUpdaters] of updateRecord.entries()) {
+ const moduleId = linkageRecord.moduleIds[specifier];
const instance = importNS.get(moduleId);
const p = instance
.initialize() // bottom up cycle tolerant
.then(() => {
const { notifiers: modNotifiers } = instance;
- const importUpdaters = updateRecord.get(specifier);
for (const [importName, updaters] of importUpdaters.entries()) {
const notify = modNotifiers[importName];
if (!notify) {
@@ -233,7 +233,7 @@ export function makeModuleInstance(
notify(updater);
}
}
- if (exportAlls.includes(specifier)) {
+ if (linkageRecord.exportAlls.includes(specifier)) {
// Make all these imports candidates.
for (const [importName, notify] of entries(modNotifiers)) {
if (candidateAll[importName] === undefined) {

MODIFY
test/test-link.js
test/test-link.js
@@ -19,13 +19,11 @@ test('evaluate linker', async t => {
functorSource: `\
${async ({ liveVar, imports }) => {
let def;
- await imports(
- new Map([['./def', new Map([['def', [$ha => (def = $ha)]]])]]),
- [],
- );
+ await imports(new Map([['./def', new Map([['def', [$ha => (def = $ha)]]])]]));
liveVar.abc(def);
}}`,
+ exportAlls: [],
imports: { './def': ['def'] },
fixedExportMap: {},
liveExportMap: { abc: ['abc', false] },
@@ -36,8 +34,9 @@ ${async ({ liveVar, imports }) => {
[
'https://www.example.com/foo/def',
{
+ exportAlls: [],
functorSource: `\
-async ({ imports, liveVar }) => { await imports(new Map(), []); liveVar.lo(456); lo ++; }`,
+async ({ imports, liveVar }) => { await imports(new Map()); liveVar.lo(456); lo ++; }`,
imports: {},
fixedExportMap: {},
liveExportMap: { def: ['lo', true] },

MODIFY
test/test-pipeline.js
test/test-pipeline.js
@@ -75,6 +75,7 @@ export default 123;
rewrite(rs) {
if (rs.sourceType === 'module') {
const staticRecord = {
+ exportAlls: [],
functorSource: `({ constVar }) => constVar.default(${JSON.stringify(
rs.src,
)});`,

MODIFY
test/test-test262.js
test/test-test262.js
@@ -138,7 +138,7 @@ function hasExcludedInfo(testInfo) {
// 'References observe the initialization of lexical bindings', // https://github.com/Agoric/make-importer/issues/40
// 'References observe the mutation of initialized bindings', // https://github.com/Agoric/make-importer/issues/40
- 'Requested modules are evaluated prior to the requesting module in source code order', // https://github.com/Agoric/make-importer/issues/43
+ // 'Requested modules are evaluated prior to the requesting module in source code order', // https://github.com/Agoric/make-importer/issues/43
'Modifications to default binding that occur after dependency has been evaluated', // https://github.com/Agoric/make-importer/issues/12

fix(moduleInstance): evaluate in source code order

Closes #43