Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Unexpected value 'ToasterModule' imported by the module 'AppModule' #55

Closed
robinkedia opened this issue Sep 3, 2016 · 9 comments

Comments

@robinkedia
Copy link

When compiling with @Angular/Compiler-cli it throws Error: Unexpected value 'ToasterModule' imported by the module 'AppModule'

Angular 2 RC6
ngc -p tsconfig.json

@Stabzs
Copy link
Owner

Stabzs commented Sep 4, 2016

Could you please provide more context around this error or a working, reproducible example? Thanks

@dagstuan
Copy link

dagstuan commented Sep 6, 2016

Can confirm this one. I have the same issue when I try to compile my project using AoT compilation. It seems Angular2-Toaster currently doesnt support AoT compiling. I'm not exactly sure why though.. will keep digging :)

@dagstuan
Copy link

dagstuan commented Sep 6, 2016

I managed to get it to build by importing the source toaster.module.ts file instead of trying to import the one exported by the lib.

as in: import { ToasterModule } from 'angular2-toaster/src/toaster.module';.

So there seems to be something wrong with how the module is bundled that causes it to not get imported correctly by ngc.

@Stabzs
Copy link
Owner

Stabzs commented Sep 6, 2016

@dagstuan Thanks for the confirmation and the investigative work.

I'll look into it.

@jcannata
Copy link

jcannata commented Sep 6, 2016

I am also having trouble with lazy-loaded routes but the error may point to the problem...

core.umd.js:5995 EXCEPTION: Uncaught (in promise): Error: BrowserModule has already been loaded. If you need access to common directives such as NgIf and NgFor from a lazy loaded module, import CommonModule instead.

Looking at the code it looks like ToasterModule is importing BrowserModule where it probably should be importing CommonModule...

@Stabzs
Copy link
Owner

Stabzs commented Sep 6, 2016

@jcannata That is a really good catch.

I didn't notice that BrowserModule was used during the code review for the ngModule contribution.

In hindsight, it makes perfect sense that this would be causing issues, since BrowserModule is needed for the entrance to the application, whereas CommonModule is needed for bootstrapping a plugin, which is what this is.

The library will always be dropped into another application for consumption. I'll take a close look at this locally. Thanks.

Stabzs added a commit that referenced this issue Sep 6, 2016
Removed BrowserModule and replaced it with CommonModule in
toaster.module.ts, since the toaster module should ALWAYS be loaded in
the context of a calling application, relying on external bootstrapping.
Potential fix for #55.

Updated dependencies order for Travis-CI build.
@Stabzs
Copy link
Owner

Stabzs commented Sep 6, 2016

Is anyone able to confirm via getting latest source (not package) that the above commit has resolved this issue? I'd love confirmation before pushing a new npm package version.

Thanks.

@jcannata
Copy link

jcannata commented Sep 6, 2016

I have forked your code, 'link'ed it locally and confirmed that it solves the issue.

@Stabzs Stabzs closed this as completed in 88d7451 Sep 6, 2016
@Stabzs
Copy link
Owner

Stabzs commented Sep 6, 2016

This is now published to NPM as 0.5.1-rc.6. Thanks @jcannata for the confirmation!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants