Rollup failed: ... is not exported by

Current behavior:

I have a service which exports an interface named Post, and it is imported in several other files. When I run ionic build android --prod --release I get the error rollup failed: ‘Post’ is not exported by src/app/services/post.service.ts even though it is exported. This ends the build process.

Related code:

post.service.ts

export interface Post {...};
export interface PostTypes {...};
@Injectable()
export class PostService {...}

some.component.ts

import {Post, PostService} from "../../services/post.service";

Other information:

Cordova CLI: 6.5.0 
Ionic Framework Version: 2.3.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.1.4
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 4.10
Node Version: v7.7.3
Xcode version: Not installed

Stack trace:


[17:58:47]  rollup failed: 'Post' is not exported by src/app/services/post.service.ts 
[17:58:47]  ionic-app-script task: "build" 
[17:58:47]  Error: 'Post' is not exported by src/app/services/post.service.ts 
Error: 'Post' is not exported by src/app/services/post.service.ts
    at error (/home/derek/Documents/side_projects/x-mobile/node_modules/rollup/dist/rollup.js:170:12)
    at Module.error$1 [as error] (/home/derek/Documents/side_projects/x-mobile/node_modules/rollup/dist/rollup.js:7997:2)
    at Module.trace (/home/derek/Documents/side_projects/x-mobile/node_modules/rollup/dist/rollup.js:8095:9)
    at ModuleScope.findDeclaration (/home/derek/Documents/side_projects/x-mobile/node_modules/rollup/dist/rollup.js:7681:22)
    at Node.bind (/home/derek/Documents/side_projects/x-mobile/node_modules/rollup/dist/rollup.js:6733:29)
    at /home/derek/Documents/side_projects/x-mobile/node_modules/rollup/dist/rollup.js:5291:50
    at Node.eachChild (/home/derek/Documents/side_projects/x-mobile/node_modules/rollup/dist/rollup.js:5308:5)
    at Node.bind (/home/derek/Documents/side_projects/x-mobile/node_modules/rollup/dist/rollup.js:5291:7)
    at Node.bind (/home/derek/Documents/side_projects/x-mobile/node_modules/rollup/dist/rollup.js:7207:53)
    at /home/derek/Documents/side_projects/x-mobile/node_modules/rollup/dist/rollup.js:5291:50
1 Like

Having the same issue here. Did you solve it?

No I haven’t found a solution. You could try and convince the github issue maintainer that this is a real problem however: https://github.com/driftyco/ionic/issues/10914#issuecomment-289371311

Now would probably be a good time to contemplate ditching rollup for webpack, in order to prepare for taking advantage of lazy page loading in upcoming releases.

What is the recommended way to switch to webpack? I used the ionic cli to create my project, is there an upcoming release where the cli will utilize webpack?

Short answer: get rid of anything that says “rollup” in package.json. Webpack has been the default for a while now. Longer answer: ionic-app-scripts README.

I did actually have a rollup script running to enable dev/prod env variables, so getting rid of that and allowing ionic to revert to using webpack fixed the problem. Thanks!