Skip to content

Instantly share code, notes, and snippets.

View caridy's full-sized avatar

Caridy Patiño caridy

  • Salesforce, Inc.
  • Miami, FL.
  • X @caridy
View GitHub Profile

Modules Harmony Simplification Effort

Disclaimer: This text is exclusively focused on the existing capabilities of the language, and does not weight into additional capabilities like wasm, or virtual modules, or compartments. Those can be discussed later on.

MVP to create a module graph

The bare minimum mechanism to create a module graph that matches ESM requires few main pieces:

  1. A portable (serializable) structure that represents the source text of the module. ModuleSource must be portable across processes and across realms.
  2. A realm based Module that closes over a ModuleSource.
@caridy
caridy / about.md
Last active April 7, 2022 19:07 — forked from rauschma/about.md
Transferring objects between a ShadowRealm and an incubator realm

Transferring objects between a ShadowRealm and an incubator realm

Material:

@caridy
caridy / export-syntax.js
Last active January 15, 2022 14:22
ES6 Module Syntax Table
// default exports
export default 42;
export default {};
export default [];
export default foo;
export default function () {}
export default class {}
export default function foo () {}
export default class foo {}
@caridy
caridy / evaluator.ts
Last active February 12, 2020 07:02
evaluator api proposal
interface EvaluatorInit {
importHook(name, referrer): Promise<ParsedModule>;
isDirectEvalHook(evalFunctionRef: any): boolean;
randomHook(): number; // Use for Math.random()
nowHook(): number; // Use for both Date.now() and new Date(),
localeHook(): string; // e.g.: 'fr-FR' - Affects appropriate ECMA-402 APIs within Realm
LocalTZAHook(): string; // This is important to be able to override for deterministic testing and such
canCompileStringsHook(source: String): boolean; // mimic CSP including nounces
thisValue?: object;
}

Updated (Aug 2nd, 2016)

API Refinements:

  • The default global scope when creating a new realm has no extra capabilities, it is confusing, we can remove it.
  • The realm object is the real power object, and users can decide to share it or not via endowments.
  • In a realm, you can create as many global scopes as you want via realmObj.createNewGlobalScope().
  • No more proxy-like API at the realm level, if you want to proxy a global, that should be used when creating a new global scope.

The API proposal:

@caridy
caridy / a.js
Last active February 3, 2017 23:28 — forked from dherman/a.js
a tiny userland registry, using a "parse" and "link" primitive
import {b} from "./b.js";
import $ from "jquery";
export function a() {
// ...
}
@caridy
caridy / README.md
Last active December 20, 2015 23:39
requiring optional client side dependencies on common dependencies

What is this?

This is a gist to showcase how to have client affinity modules that are required by common affinity modules without breaking the app when trying to use the common affinity modules on the server side.

Instalation

npm install
node app.js
@caridy
caridy / README.md
Last active December 20, 2015 18:59
how to deal with vendor scripts when using `express-yui`

What is this?

This is a gist to showcase how to deal with vendor scripts when using express-yui, in this particular case, loading jquery as a yui module.

Instalation

npm install
node app.js
@caridy
caridy / README.md
Last active December 20, 2015 16:28
Patching YUI Core Modules with `express-yui`

What is this?

This is a gist to showcase how to patch a yui core module when using express-yui, in this particular case, patching the router module by defining a new module router-patched as a replacement for the original module core module router.

Instalation

npm install
node app.js
@caridy
caridy / README.md
Last active December 20, 2015 07:19
express-routes-notes

What is this?

This is a prototype for the low-level api to serialize express routes into the client side.

Installation

npm install
node simple.js
node complex.js