Skip to content

Commit

Permalink
feat(compartment-mapper): add Compartment option to captureFromMap (#…
Browse files Browse the repository at this point in the history
…2612)

This just allows `captureFromMap()` to receive a `Compartment` option
which is passed thru to `link()`.
  • Loading branch information
boneskull authored Oct 24, 2024
2 parents fad5c68 + 1ac2156 commit 7c32c62
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/compartment-mapper/src/capture-lite.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ import { unpackReadPowers } from './powers.js';

const { freeze, assign, create, fromEntries, entries, keys } = Object;

const defaultCompartment = Compartment;

/**
* We attempt to produce compartment maps that are consistent regardless of
* whether the packages were originally laid out on disk for development or
Expand Down Expand Up @@ -266,6 +268,7 @@ export const captureFromMap = async (powers, compartmentMap, options = {}) => {
sourceMapHook = undefined,
parserForLanguage: parserForLanguageOption = {},
languageForExtension: languageForExtensionOption = {},
Compartment = defaultCompartment,
} = options;

const parserForLanguage = freeze(
Expand Down Expand Up @@ -309,6 +312,7 @@ export const captureFromMap = async (powers, compartmentMap, options = {}) => {
parserForLanguage,
languageForExtension,
archiveOnly: true,
Compartment,
});
await compartment.load(entryModuleSpecifier);
if (policy) {
Expand Down
1 change: 1 addition & 0 deletions packages/compartment-mapper/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@ export {};
* @property {Record<string, ParserImplementation>} [parserForLanguage]
* @property {LanguageForExtension} [languageForExtension]
* @property {ExitModuleImportNowHook} [importNowHook]
* @property {typeof Compartment} [Compartment]
*/

/**
Expand Down

0 comments on commit 7c32c62

Please sign in to comment.