-
Notifications
You must be signed in to change notification settings - Fork 12k
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
1.0.1 -> 1.1.3 broke DI -- Uncaught Error: Can't resolve all parameters for providesGuard(?) #6788
Comments
I think this isn't as much a CLI build problem as it is a runtime Angular problem. It sounds like a very similar situation to #2034. You're using an interface as a DI token, which is an approach that has some problems. See #2034 (comment) for a more detailed answer about this. Can you tell me if making |
No, using a class unfortunately did not help (though I can understand their reasons).
… On Jun 27, 2017, at 9:57 AM, Filipe Silva ***@***.***> wrote:
I think this isn't as much a CLI build problem as it is a runtime Angular problem. It sounds like a very similar situation to #2034 <#2034>.
You're using an interface as a DI token, which is an approach that has some problems. See #2034 (comment) <#2034 (comment)> for a more detailed answer about this.
Can you tell me if making IRestConfig a class instead of an interface helps?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#6788 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AFKwS_svH5cDBMWBuuyYEzGvAu-xONpWks5sIQpegaJpZM4ODxxH>.
|
I can take a look if you can make a simple repro for this issue. |
I'm pretty deep into the rabbit hole at this point. The interface being defined in a different file and imported was ultimately the main issue even though using a class did nothing to rectify the problem (the other module is where the related service was configured, so this was originally an attempt at avoiding a circular dependency on the interface). I’ve since flipped that paradigm to the more standard approach of having the service be part of the ModuleWithProviders This error is related to my development library having been linked into the app’s One suggested "fix" is to delete the linked-in library's
However, now at runtime my library's use of
The above would work fine before v1.1.3. In fact re-installing So while I agree that it's not necessarily a direct problem of running the transpiler, it certainly has something to do with these two versions of the CLI package. And even though I've now mitigated the original issue, it's pretty irrelevant because everything I fix to make this library to work with this version of the CLI-generated and served app just uncovers one more thing that is now broken, specifically for this version of the CLI package. |
Mind you, when I asked for repro steps I meant repro steps for me, not for you... when you say There's some guidance on how to work with linked libraries here: https://github.com/angular/angular-cli/wiki/stories-linked-library. I'm not sure what your workflow is but you do need to build your library and not rely on the CLI to compile it for you. It maybe might work if you let the CLI compile it, but there's loads of scenarios where that won't work. I think the PR where something changed that allowed your scenario to work was #6276, where we fixed some some more serious problems and then provided the linked lib guidance I linked above. |
I apologize for my earlier terseness. I've used my above steps to generate a library and application from @angular/cli, which is now at 1.4.2 and also having the same problem. You can find the generated app and library here. Your repro steps should be:
The resulting directory structure looks like this:
When you open a browser to the server, Angular will exception out with:
The only solution, I've found, to work in a development environment with @angular/cli >1.0.1 is to modify the gulpfile of the library so that it is generated outside of the repository's top level directory (mimicking the deployment behavior).
The resulting directory structure looks like this:
This prevents the server from traversing down into From my perspective, all I "did" was upgrade from 1.0.1 to something newer of @angular/cli, and that's when the directory traversal behavior changed, breaking the previously-working method of linking a development library's distribution directory into an application. And the break occurred because the server (in my opinion, erroneously) starts looking in subdirectories of the app's |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug Report or Feature Request (mark with an
x
)Versions.
macOS Sierra:
Repro steps.
npm run start
(which isng serve
)The log given by the failure.
Desired functionality.
Would like to know how to correct the ModuleWithProviders guard so that it's compatible going forward if this change in behavior between 1.0.1 and 1.1.3 is permanent. If it's a bug in 1.1.3, then a fix would be good. The work-around right now is to use 1.0.1.
Mention any other details that might be useful.
Here is a sanitized version of the module that reproduces the issue:
At the app module, one would add
TestModule.forRoot({ port: 1234 })
, for example, into theimports
.Changing from 1.0.1 to 1.1.3 of
@angular/cli
results in the error (at the browser) that the argument toprovidesGuard
couldn't be resolved.EDIT: Was missing code ticks ahead of the last block of code.
The text was updated successfully, but these errors were encountered: