The error is very clear and specific.
Error: it is not possible to call the namespace ("moment") on an error (/ Users / chris / angular-library / node_modules / rollup / dist / rollup.js: 185: 14)
This complies with the ES module specification.
This means that the following is an invalid way to import the moment, because the module namespace object, for example, created by * as ns , cannot be called.
import * as moment from 'moment';
The correct form is the form in which ngc causes an error on
import moment from 'moment';
First, to do this, you need to specify the --allowSyntheticDefaultImports flag.
tsconfig.json
{ "compilerOptions": { "allowSyntheticDefaultImports": true } }
Assuming ngc recognizes this option, you still have an additional problem for development.
The flag is higher for users of tools such as SystemJS or Webpack that perform synthesis, allowing this code to check the type.
Note that if you compile CommonJS modules --module commonjs , the correct import syntax will be
import moment = require('moment');
Aluan Haddad
source share