Rollup problem using external module on ionic 2 RC0

Referring to my previous post, I was having problem to import an external npm modules into my app…

Turn out, the error is actually related to rollup (so, ionic decided to use rollup instead of webpack)

Im using several external module like asyncjs and importing the module using

import * as async from 'async'

but then, during compilation, i get these errors spewed into my terminal…

[21:57:59]  rollup: Export 'parallel' is not defined by '/my-app/.tmp/app/app.component.js'
[21:57:59]  rollup: Export 'defer' is not defined by '/my-app/.tmp/pages/authentication/main/main.js'
[21:57:59]  rollup: Export 'waterfall' is not defined by '/my-app/.tmp/pages/authentication/main/main.js'

Anyone have any ideas?

Ok… i found the solution, it seems that i supposed to import and assign to some variable (a different one from the module name) right away… although it looks kind of counterintuitive…

instead of this, which will throw error

import * as async from 'async'

this works

import myasynclib from 'async'

its weird… common sense dictate that this sounds like importing myasynclib out of async… but instead, it import async and assign to a variable called myasynclib… hurm…

can anyone confirm this?

2 Likes

Well this worked for me too, so it’s definitely a solution. I was using ‘moment’ and had to do the same thing.