"ionic serve" ignoring barrel index.ts files after upgrading to 2.0.0-rc.1

After upgrading to Ionic 2 RC1 following these instructions, I get the following error running ionic serve:

bundle failed: Could not resolve ‘…/backend’ from /home/tkem/src/openlap/src/app/app.module.ts

Running ionic build android or npm run build works fine, as before.

AFAICS this is because backend is actually a barrel, i.e. in app.modules.ts, I have

import { BackendModule } from ‘…/backend’;

and in ../backend/index.ts:

export * from ‘./backend.module’;

If I change app.modules.ts to

import { BackendModule } from ‘…/backend/backend.module’;

it seems to work, but fails with the next barrel import. As I said, this seems to be only an issue with ionic serve.

3 Likes

P.S.: I would have filed a proper bug report, but I’m not sure whether this is affected by ionic-angular, ionic-cli, or @ionic/app-scripts; as recommended in the Ionic blog post, I ended up upgrading all three…

1 Like

One more.

After upgrading to @ionic/app-scripts 0.0.34 I get module resolving errors for code in all index.ts files:
e.g.

  • I have a file under /providers/abc/index.ts and export something from here.
  • in another file I could import it with import { ABC } from './providers/abc'

After upgrading to 0.0.34 only import { ABC } from './providers/abc/index' works.

I have added /index to all such imports for now to temporary solve the issue.

1 Like

I have the same issue. Can you be more clear if you have resolved your issue?

I got the same issue from a brand new RC ionic project…

1 Like

Just noticed that ionic-app-scripts v0.0.36 is available, and upgrading seems to fix the bundle issue with index files. Probably due to

So thanks for the quick fix, Dan! Awesome!

2 Likes

Awesome! It works now!

I’m new to ionic2, and I’m experiencing the same problem with an sdk that uses barrels (this sdk works ok in a project managed with angular-cli). The fix mentioned about ionic-app-scripts doesn’t work for me.
The ionic2 project has been created just yesterday with ionic cli, this is the output of ionic info:

Your system information:

Cordova CLI: 6.3.1
Gulp version: CLI version 3.9.1
Gulp local:
Ionic Framework Version: 2.0.0-rc.1
Ionic CLI Version: 2.1.1
Ionic App Lib Version: 2.1.1
Ionic App Scripts Version: 0.0.36
OS:
Node Version: v6.5.0