4

I'd like to use the es6-module-loader polyfill with the "module" tag in the browser: https://github.com/ModuleLoader/es6-module-loader#module-tag

It works by traversing all the files imported, looking for import/export tags and transpiling them. Traceur is the default due to babel no longer supporting dynamic, in-browser use.

The problem is that traceur transpiles all es6 features, while I want to transpile only the import/export statements due to good es6 browser support now (Canary is > 95% es6 complete!).

I tried turning off all the options that looked right, see below, but got lots of odd errors. I have not yet tried using the earlier babel 5.x in-browser for transpiling.

Is there any simple way to to get <script src="module"> working? I presume es6-module-loader is the best approach but any suggestion appreciated! A better set of traceur options? Try babel 5.x?

System.traceurOptions = { arrowFunctions: false, blockBinding: false, classes: false, computedPropertyNames: false, defaultParameters: false, destructuring: false, forOf: false, generators: false, numericLiterals: false, propertyMethods: false, propertyNameShorthand: false, restParameters: false, spread: false, symbols: false, templateLiterals: false, unicodeEscapeSequences: false, unicodeExpressions: false }

5
  • Just curious as to why you're doing this as opposed to bundling modules with a loader? Commented Mar 1, 2016 at 21:24
  • 2
    Good question. Mainly our group wants to 1) minimize/simplify workflow 2) be as close as possible to the browser module loader when it is implemented. Webpack, browserify, etc all are great, and maybe I just don't get them at this point. I presumed es6 would cut down on them rather than add to the workflow soup! And bundling? With http2/ bundling may be an anti-pattern. Commented Mar 1, 2016 at 22:27
  • Wanting to be as close to the ground to http2 modules is a reasonable response---the overhead in regards to workflow by module bundling with webpack is very low if you just download a boilerplate and be done with it. You can get more into it over a weekend if you need to do some interesting customizations. I think that's preferable until browsers load modules natively Commented Mar 1, 2016 at 22:40
  • 1
    I think presuming bundling won't be important with http2 isn't quite right. http2 will still have tons of round-trip requests unless you've configured your server with http2 push, and the only way push will work well is by having walked the dependency graph of your files just like a bundler would. You're never going to get around having some kind of dependency-processing step if you want performant loading in production. Commented Mar 2, 2016 at 0:36
  • Possible duplicate of generate javascript using xml and xsl Commented Oct 11, 2016 at 14:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.