I'm building an Angular (2+) component library using jvandemo/generator-angular2-library as a starter, which uses Rollup as a module builder. The component I am creating in the library uses MomentJS.
I've had various build issues with the inclusion of MomentJS.
I first used import moment from 'moment';
to import moment into the component, but that produces the following error at build;
[17:26:28] Starting 'ngc'...
Error at /Users/chris/angular-library/.tmp/components/my-library/my-component.component.ts:6:8: Module '"/Users/chris/my-library/node_modules/moment/moment"' has no default export.
I found this SO question that said to use import * as moment from 'moment';
however with that I get;
'moment' is imported by build/components/my-component.component.js, but could not be resolved – treating it as an external dependency
events.js:182
throw er; // Unhandled 'error' event
^
Error: Cannot call a namespace ('moment')
at error (/Users/chris/angular-library/node_modules/rollup/dist/rollup.js:185:14)
As far as I can tell these are the only two options and I can't get either to work, what am I missing?
Edit
I've added this issue to the library's Github repo that contains minimalistic replication steps