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
Here is what I did to make work moment with typescript (at 2.1.6) and rollup (0.41.4).
To import moment, keep the standard way:
import * as moment from 'moment';
import moment from 'moment'; is non-standard for a package without a default export, it will result an error at runtime: moment_1.default is not a function
In typescript use moment with by casting moment as any, and call the default function:
var momentFunc = (moment as any).default ? (moment as any).default : moment;
var newFormat = momentFunc(value).format( format );
moment(value).format(format) will result an error at rollup tree shaking: Cannot call a namespace ('moment')