Open vojtajina opened 10 years ago
@guybedford
What mess?
Traceur compiles itself using 'register'. You can load these modules with only ModuleStore, that's what we do do bootstrap.
If you don't want a system registry, use 'inline'.
I know it is not ideal but backwards compatibility around this may be important now - we've been communicating for 9 months now the modules=instantiate
option, so I'd be hesitant to change this.
You can use System.register on its own by simply adding it at the end of es6-module-loader.js.
What mess?
I agree that this is a bit messy.
Here are the modes I would prefer
It's worth looking at es6-module-transpiler for alternative approaches. I think they do it pretty well. Out of the box they only have "bundle." There are plugins for AMD and for CJS. I don't think they have anything System-related (but I never understood what parts of System are standard and which are @guybedford's extensions).
Well I think we should switch to use 'instantiate' for Traceur and remove 'register'. As far as I know, es6-module-loader uses 'instantiate' for bundles. I tried switch one time as part of trying to replace TraceurLoader with es6-module-loader, but I could not solve all of the problems. May just the switch would be easier.
I would be against using 'inline' for Traceur, it's too hard to read.
@arv what does bundle mean? Is it all files into one?
Right now, I have to use es6-module-loader and systemjs (with "register" extension) to load Traceur's output. It should be possible to load code generated by Traceur using plain es6-module-loader.
To me a good solution is the one we use for Traceur. Start with runtime file like bin/traceurRuntime.js
and a compiled file generated from a command line compile like ./traceur <options> --module <rootModule>
. Including both files in <script>
tags and you can run a web page. Or add more <rootModule>
based files. Or concatenate them. Or try out the code without compilation by putting a <script> tag with
bin/traceur.jsin the web page and using
System.import(. Or use
es6-module-loaderthen use
System.import(. If
bin/traceurRuntime.js` is really too large, build a smaller one with a custom script.
If you want to go to the next level and mix cjs/requirejs into the app use type='module'
tags, and allow both static and dynamic loads then you want @guybedford's systemjs, it deals with all that.
My suggestion:
1/ rename "instantiate" to something like "es6loader" 2/ remove "register" - what is the purpose of it? (AFAIK, there is no
Loader.register
API in the spec) 3/ make it possible to use modules="es6loader" output with es6-module-loader, without systemjs - what needs to be done?What do you think? Am I missing something?