2

I'm stuck with dynamic requering es6 modules by invoking them through:

System.import('SOME_PATH').then(function (MODULE_FROM_SOME_PATH) {});

It works well with es6-module-loader and babel runtime compilation in browser, but when i want to precompile it to ES5 syntax (for production uses) it just passes System.import expression in code, leaving in practically untouched, just replacing System.import with equivalent System['import'].

I've tried gulp-babel and babel npm package. So when opened in browser it gives expected module loading error. How can i transpile my code to AMD syntax for ES5. Hoping for your help.

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Erik
  • 23
  • 4
  • It's not exactly clear what you want to do - is the aim to load modules that have been transcompiled to ES5, in which case the modules will have to be transcompiled to System.register modules. – user5321531 Apr 09 '15 at 16:49
  • Do you mean changing System.import('aModule').then(fn) to require(['aModule'], fn)? Or even better, something equivalent but more UMD like? – Thodoris Greasidis May 14 '15 at 20:00

1 Answers1

0

Just pushed babel-plugin-system-import-transformer that replaces System.import to the equivalent UMD import (AMD, CommonnJS & Global module imports).

I have also created a separate localforage branch that uses System.import statements as an example.

Hope this helps.