feat(compartment-mapper): Thread compartment constructor
MODIFY
packages/compartment-mapper/NEWS.md
packages/compartment-mapper/NEWS.md
@@ -7,6 +7,8 @@ User-visible changes to the compartment mapper:
arguments.
* The `import` options bag now also accepts `globalLexicals` and `transforms`,
passing these without alteration to each `Compartment`.
+* The `import` options bag now also accepts a `Compartment` constructor, to use
+ instead of the one assumed to be present globally.
## Release 0.1.0 (2020-09-21)

MODIFY
packages/compartment-mapper/src/import-archive.js
packages/compartment-mapper/src/import-archive.js
@@ -39,7 +39,13 @@ export const parseArchive = async (archiveBytes, archiveLocation) => {
const compartmentMap = json.parse(compartmentMapText, "compartment-map.json");
const execute = options => {
- const { globals, globalLexicals, modules, transforms } = options;
+ const {
+ globals,
+ globalLexicals,
+ modules,
+ transforms,
+ Compartment
+ } = options;
const {
compartments,
entry: { module: moduleSpecifier }
@@ -50,7 +56,8 @@ export const parseArchive = async (archiveBytes, archiveLocation) => {
globals,
globalLexicals,
modules,
- transforms
+ transforms,
+ Compartment
});
return compartment.import(moduleSpecifier);
};

MODIFY
packages/compartment-mapper/src/import.js
packages/compartment-mapper/src/import.js
@@ -26,14 +26,21 @@ export const loadLocation = async (read, moduleLocation) => {
);
const execute = async (options = {}) => {
- const { globals, globalLexicals, modules, transforms } = options;
+ const {
+ globals,
+ globalLexicals,
+ modules,
+ transforms,
+ Compartment
+ } = options;
const makeImportHook = makeImportHookMaker(read, packageLocation);
const compartment = assemble(compartmentMap, {
makeImportHook,
globals,
globalLexicals,
modules,
- transforms
+ transforms,
+ Compartment
});
return compartment.import(moduleSpecifier);
};

MODIFY
packages/compartment-mapper/test/main.test.js
packages/compartment-mapper/test/main.test.js
@@ -103,7 +103,8 @@ test("loadLocation", async t => {
const { namespace } = await application.import({
globals,
globalLexicals,
- modules
+ modules,
+ Compartment
});
assertFixture(t, namespace);
});
@@ -114,7 +115,8 @@ test("importLocation", async t => {
const { namespace } = await importLocation(read, fixture, {
globals,
globalLexicals,
- modules
+ modules,
+ Compartment
});
assertFixture(t, namespace);
});
@@ -127,7 +129,8 @@ test("makeArchive / parseArchive", async t => {
const { namespace } = await application.import({
globals,
globalLexicals,
- modules
+ modules,
+ Compartment
});
assertFixture(t, namespace);
});
@@ -151,7 +154,8 @@ test("writeArchive / loadArchive", async t => {
const { namespace } = await application.import({
globals,
globalLexicals,
- modules
+ modules,
+ Compartment
});
assertFixture(t, namespace);
});
@@ -174,7 +178,8 @@ test("writeArchive / importArchive", async t => {
const { namespace } = await importArchive(fakeRead, "app.agar", {
globals,
globalLexicals,
- modules
+ modules,
+ Compartment
});
assertFixture(t, namespace);
});

feat(compartment-mapper): Thread compartment constructor