Chatie / db

Database for Chatie
https://www.chatie.io
Apache License 2.0
0 stars 0 forks source link

AOT: Encountered undefined provider! Error: The Angular AoT build failed. #30

Open huan opened 6 years ago

huan commented 6 years ago

When this module is imported by @chatie/app, npm run ionic:build --aot said Encountered undefined provider!.

After diving into the code, the issue https://github.com/Chatie/app/issues/33 is caused by this module @chatie/db.

Even an empty empty import could be able to cause the error message:

Encountered undefined provider! Error: The Angular AoT build failed. Usually this means you have a circular dependencies (might be caused by using 'barrel' index.ts files.

import {} from '@chatie/db'

Wired.

See Also

huan commented 6 years ago

UPDATE

I found this issue caused by using 'barrel' index.ts files, just as the error message said.

However, it's very strange that it's just a very simple barrel index.ts, there are no circle dependencies at all.

https://github.com/Chatie/db/blob/de17acc7c2d98d77b285776b0a5467362bfe4ef2/src/db.module.ts#L9-L15

If I change the above code to

- import { BotieStore }   from './botie/'
+ import { BotieStore }   from './botie/botie-store'
- import { GiftieStore }  from './giftie'
+ import { GiftieStore }  from './giftie/giftie-store'
- import { HostieStore }  from './hostie'
+ import { HostieStore }  from './hostie/hostie-store'

Then it will work with AOT in @chatie/app.

Wired.