Angular 2
typescript 2
のコードはthe Intl.js polyfillです。Rollup.jsでIntl.jsモジュールを使用する方法
をtsconfig.json
に設定して、Rollup.jsをrecommended by Angularとして使用してツリーシェイクを可能にしました。私のコンポーネントで、私はちょうどimport 'intl'
私は、ブラウザでアプリケーションを実行しない場合、私はes2015
rollup.configにライブラリを変換するためにrollup-plugin-commonjs
を使用してみましたが、エラー
global is not defined
を取得します.js
plugins: [
nodeResolve({jsnext: true, module: true}),
commonjs({
include: 'node_modules/intl/**/*',
})
]
ブラウザでアプリを実行すると、行で
IntlPolyfill is not defined
:
IntlPolyfill.__addLocaleData({locale:"en-US",...});
I noticed hereそれはrollup
と互換性がありますので、ライブラリはes6
で書かれていることを示すエラートン。どのようにこのライブラリをes6
モジュールとして使用するためのヒント?
私は 'en-us'ロケールだけを使用しているので、' intl/index.js'を編集し、6行目を[this](https://github.com/andyearnshaw/Intl.js)に変更しました。 /blob/master/index.js#L6)から[this](http://pastebin.com/GfYSL7t2)に変更してください。これにより、バンドルのサイズを大幅に縮小することができました。あなたが考えるこの利益を維持するためにあなたのソリューションを適応させることはできますか? – BeetleJuice
'locale-data/complete.js'を' locale-data/jsonp/replace 'に置き換えるには、[rollup-plugin-replace](https://github.com/rollup/rollup-plugin-replace) es-US.js' –