On Tue, Oct 8, 2013 at 8:24 AM, Till Schneidereit
<t...@tillschneidereit.net> wrote:
> Interesting. I wonder if the monkey patching will even still work once we
> have es6 modules and use them in the platform.
>
> Jason and Eddy, you probably know, but I'm under the impression that
monkey
> patching an es6 module requires funneling it through a custom module
loader.
> Maybe the platform should do that by default and by default allow
addons to
> apply transforms to them?
Here's the simplest way to monkeypatch an ES6 module:
1. Use System.get("x") or System.import("x", callback) to get the
Module object.
2. Make your own Module object to replace it (which is like, `new
Module({a: my_a, b: my_b})`)
3. Use System.set(x, my_module) to put your patched module into the
loader.
No custom module loader is needed for that. However, the scope of this
style of monkeypatching is strictly per-Loader, and each global gets its
own Loader (like all other builtins). We do need some customization to
support system-wide monkeypatching. But we were going to need some
customization anyway just for stuff like mapping module names to chrome:
URLs or whatever.
-j
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform