How to integrate ES6 Module syntax in RequireJS project

允我心安 提交于 2020-04-11 02:07:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!