Skip to content

Instantly share code, notes, and snippets.

@jfparadis
Last active January 10, 2020 06:19
Show Gist options
  • Save jfparadis/6f85bacd9e4b201ff69676c43ebcc5ab to your computer and use it in GitHub Desktop.
Save jfparadis/6f85bacd9e4b201ff69676c43ebcc5ab to your computer and use it in GitHub Desktop.
XS module map vs namespace

XS module map vs namespace

Results

  1. Module map can only be populated from Compartment map
  2. Any attempt to use the namespaces fails

Type check

typeof Compartment.map.mod
// symbol
import * as ns from "./mod";
typeof ns;
// object

Compartment.map in module map: works

// main.js
let { mod } = Compartment.map;
new Compartment("mod", {}, { mod });

// mod.js
trace("mod loaded");
export default function {
}

// mod loaded

import ns in module map: fails

// main.js
import * as ns from "./mod";
new Compartment("mod", {}, { mod: ns });

// mod.js
export default function {
}

// # Break: Compartment: module "mod" not found!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment