Using Rollup for Angular 2's AoT compiler and importing Moment.js

后端 未结 9 1762
天涯浪人
天涯浪人 2020-12-24 13:34

I\'m trying to follow the official AoT guide for Angular 2, and I\'m using Moment.js in my application. Moment.js is on my packages.json file, and I\'m using versio

9条回答
  •  心在旅途
    2020-12-24 13:57

    I found a nice solution for the problem at hand:

    Npm-install additional package moment-es6 which provides a default export. Then import from 'moment-es6' instead of from 'moment':

    import moment from 'moment-es6';

    • For use with systemjs, add the following to the systemjs.config.js map section:
      'moment-es6': 'npm:moment-es6/index.js'

    • add 'node_modules/moment-es6/**' to the include's of your rollup configs commonjs section (rollup-plugin-commonjs)

提交回复
热议问题