refactor(compartment-mapper): Thread resolvers through link result
This is necessary for bundling, since the bundler needs to directly
inspect the module static record.
MODIFY
packages/compartment-mapper/src/assemble.js
packages/compartment-mapper/src/assemble.js
@@ -276,6 +276,8 @@ export const link = (
/** @type {Record<string, Compartment>} */
const compartments = {};
+ /** @type {Record<string, ResolveHook>} */
+ const resolvers = {};
for (const [compartmentName, compartmentDescriptor] of entries(
compartmentDescriptors,
)) {
@@ -306,6 +308,7 @@ export const link = (
exitModules,
);
const resolveHook = resolve;
+ resolvers[compartmentName] = resolve;
// TODO also thread powers selectively.
const compartment = new Compartment(globals, exitModules, {
@@ -335,6 +338,7 @@ export const link = (
return {
compartment,
compartments,
+ resolvers,
};
};

MODIFY
packages/compartment-mapper/src/types.js
packages/compartment-mapper/src/types.js
// Shared machinery for assembling applications:
+/**
+ * @callback ResolveHook
+ * @param {string} importSpecifier
+ * @param {string} referrerSpecifier
+ * @returns {string} moduleSpecifier
+ */
+
/**
* @callback ImportHookMaker
* @param {string} packageLocation

refactor(compartment-mapper): Thread resolvers through link result

This is necessary for bundling, since the bundler needs to directly
inspect the module static record.