【发布时间】:2017-02-17 17:08:54
【问题描述】:
我在typescript 2 中编码的Angular 2 应用程序使用the Intl.js polyfill。
我在tsconfig.json 中设置了module:"es2015",以允许使用Rollup.js 作为recommended by Angular 进行树摇动。在我的组件中,我只是做import 'intl'
当我在浏览器中运行应用程序时,我得到了错误
全局未定义
我尝试使用rollup-plugin-commonjs 将库转换为es2015
rollup.config.js
plugins: [
nodeResolve({jsnext: true, module: true}),
commonjs({
include: 'node_modules/intl/**/*',
})
]
当我在浏览器中运行应用程序时,出现错误:
IntlPolyfill 未定义
在线:
IntlPolyfill.__addLocaleData({locale:"en-US",...});
I noticed here 表示该库是用es6 编写的,因此它应该与rollup 兼容。关于如何将此库用作es6 模块的任何提示?
【问题讨论】:
标签: angular module bundling-and-minification rollupjs