Error from rollup when importing moment.js with rc0

I get have a project where use moment.js and imports moment.js using the recommended import syntax

import * as moment from "moment";

This worked fine in beta-11 but now in rc0 with rollup as part of the build process I get the following error when running ionic serve

[21:14:48]  bundle dev started ...
[21:14:54]  Error: Cannot call a namespace ('moment')
    at error (/Projects/myProject/node_modules/rollup/dist/rollup.js:5406:12)
    at CallExpression.bind (/Projects/myProject/node_modules/rollup/dist/rollup.js:5829:5)
    at /Projects/myProject/node_modules/rollup/dist/rollup.js:5151:50
    at MemberExpression.eachChild (/Projects/myProject/node_modules/rollup/dist/rollup.js:5168:5)
    at MemberExpression.bind (/Projects/myProject/node_modules/rollup/dist/rollup.js:5151:7)
    at MemberExpression.bind (/Projects/myProject/node_modules/rollup/dist/rollup.js:6693:24)
    at /Projects/myProject/node_modules/rollup/dist/rollup.js:5151:50
    at CallExpression.eachChild (/Projects/myProject/node_modules/rollup/dist/rollup.js:5168:5)
    at CallExpression.bind (/Projects/myProject/node_modules/rollup/dist/rollup.js:5151:7)
    at CallExpression.bind (/Projects/myProject/node_modules/rollup/dist/rollup.js:5842:23)

Any help resolving this issue would be greatly appreciated.

3 Likes

Had the same, changed it to:

Import moment from ‘moment’

17 Likes

Thanks so much @fishgrind! That was exactly the problem.

Also, I was using import Moment from 'moment' instead of import moment from 'moment' and the compiler had issues with the capital letter. Keep it lower case and it should work.

2 Likes

It is neat being able to import moment just the way we import other modules, don’t you think? :slight_smile:

1 Like

I’ve tried this and am still getting the console error:

Error: Cannot call a namespace ('moment')

Anything else you did?