问题
I'm looking for a way to use ES6 Modules (import/export) syntax in my current RequireJS project. I can run my project directly in a recent browser, without build or Babel transformation. I build my project with r.js and Babel only for production.
We would like to start building ES6 modules and use it with requireJS. Is there a way to do that ?
NB : RequireJS does not load dependencies written in ES6.
回答1:
Yes, RequireJS should be compatible with Babel's es2015-modules-umd plugin. So you should be able to use import
and export
in your files during development with a modern browser that supports modules, then use r.js and Babel w/that plugin for production.
来源:https://stackoverflow.com/questions/49631520/how-to-integrate-es6-module-syntax-in-requirejs-project