umdjs / umd

UMD (Universal Module Definition) patterns for JavaScript modules that work everywhere.
MIT License
7.42k stars 423 forks source link

Add support for System.register #60

Open thgreasi opened 9 years ago

thgreasi commented 9 years ago

As noted at es6-module-loader wiki:

System.register can be considered as a new module format...

How about extending the UMD pattern to also use System.register? Something like:

if (System && typeof System.register === "function") {
    System.register(['b'], factory);
} else if (typeof define === 'function' && define.amd) {
    // AMD. Register as an anonymous module.
    define(['exports', 'b'], factory);
} else if (typeof exports === 'object') {
    // CommonJS
    factory(exports, require('b'));
} else {
    // Browser globals
    factory((root.commonJsStrict = {}), root.b);
}

A similar discussion also takes place at mozilla/localForage#158.

jrburke commented 9 years ago

For me, System.register is still speculative, and its format could change depending on how the loader API for the ES module loader shakes out. The use of System in general is trying to mimic or guess at the ES API, and it is just not close to done. I also expect the loaders that do implement System.register would know how to load commonjs or amd modules.

EvanCarroll commented 9 years ago

Does anything support System.register?

$ node --version
v5.0.0
node --harmony_modules
> System.register()
ReferenceError: System is not defined
    at repl:1:1
    at REPLServer.defaultEval (repl.js:248:27)
    at bound (domain.js:280:14)
    at REPLServer.runBound [as eval] (domain.js:293:12)
    at REPLServer.<anonymous> (repl.js:412:12)
    at emitOne (events.js:82:20)
    at REPLServer.emit (events.js:169:7)
    at REPLServer.Interface._onLine (readline.js:210:10)
    at REPLServer.Interface._line (readline.js:549:8)
    at REPLServer.Interface._ttyWrite (readline.js:826:14)