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
Host should not return a redirect source file from getSourceFile
#22524
Comments
This is actually not a new problem, see angular/angular-cli/issues/8332 Wish they would have taken it seriously back then, now we have the mess as TS 2.6 is supported. |
Here is another reproduction using Angular CLI with linked dependencies and preliminary investigation of the problem:
|
Same problem here using Typescript 2.6.2, webpack 3.10, Angular 5.2.x with ngtools/webpack 1.10.2 (compiler-cli 5.2). Interestingly, the problem only seemed to start for me after converting my webpack config to typescript. Reverting it back to JavaScript resolves the problem. |
@kspearrin It's because the issue, at least in my case, is duplicate typings for UglifyJS, which is included in webpack. If you have the config in JS it won't use typings hence no error. Good to know though, it's not super important for us to have the config in TS. |
Yes I think it was something to do with the typings that were added for that conversion. See here for the commit that broke things: bitwarden/clients@df4e7f0 |
Changing the webpack configs to JS was not sufficient in my case. But as soon as I removed the [at]types/webpack and [at]types/webpack-merge packages from my project the bug disappeared. Finally a current TS version for my projects! |
I was able to solve this issue by disabling AOT in ngtools/webpack 1.10.2 by setting the skipCodeGeneration option to true. new AngularCompilerPlugin({
...options,
skipCodeGeneration: true
}) |
Hi @samelliottdlt (et all), I'm confused by your ngtools/webpack version, you said:
I have:
Am I on the wrong version??? Just wondering... Either way, I keep getting the same error (and none of the above workarounds/fixes have helped):
node --version && npm --version
package.json
webpack.common.ts
webpack.localhost.ts
tsconfig.json
Thanks so much! |
@charlieargue you can try installing 1.10.2 rather than the rc version and set skipCodeGeneration to true. maybe that'll solve your issue. note that this is not a great solution but at least it allows us to keep development rolling until a fix is shipped :) run this command to install the latest ngtools/webpack |
Thx @samelliottdlt for the quick response! So I'm on:
And I had to switch from using:
SWITCHED TO:
This last approach compiles all my modules successfully:
but the site never loads the angular application, and just sits on Loading....... And adding, to
Nothing I'm trying has worked, so without some help/luck, I might have to go back to the |
Hi, just checking in and wanted to see if I'd missed something, or if there was some more information I could provide to help! Thanks again! |
In the same boat. Any update on a fix for this? |
Should this issue be logged to Angular CLI or ngtools/webpack? They keep moving the compiler logic around. It's hard to keep track. Please fix this issue. It is the only one that's preventing us from using AOT in dev builds. |
this still happen in cli v6 with aot: true in "serve" target. |
Confirming that after upgrading to Angular 6, still have the same ERROR. Thanks again for any guidance on this! Error
relevant package.json:
|
Any progress on this? Having same issue with production builds using angular 6. |
I was finally able to find the root cause of the problem (for my use case at least). This bug shows its ugly head whenever there a duplicate typings in the project. In my case it reappeared when upgrading to redux 4.0.0 in a project, and some plugins still have a dependency on 3.x.x. So I ended up with
and redux brings it's own typings ... twice in my case. removing the nested node_modules caused the incremental build to finally run on TS 2.7. How did I find the culprits? Basically just put a if(newSourceFile.redirectInfo)-wrapped log before the compiled source at and then the bad files show up. At least that worked in my case. As a workaround I added a postinstall script to package.json that removes the folders, like https://github.com/DcsMarcRemolt/ngx-starter-new/blob/master/package.json#L22 Oh and a colleague also had a node_modules folder ABOVE the project folder also containing duplicate typings. Removing that finally fixed it on his machine too. |
@DcsMarcRemolt Sorry that you had to spend additional time on this. I thought the root cause was clear in my original post since I posted a solution for it, and the PR I linked to states "Issue happens due to identical *.d.ts file found via two paths in the compilation." I've updated my post with this to avoid any future confusion. |
@JonWallsten Actually that was my bad. This problem is so old (bugged me long before this issue), I simply forgot that you already analyzed this thoroughly. The problem reappeared for me last week after a few months break, so I dug into it and reported my findings. |
Actually, I didn't realize there was a solution on this thread until today and thanks to @DcsMarcRemolt -- so it was not clear, and others failed to point it out for months, that there was one -- so my bad, but again, thanks to @DcsMarcRemolt for clearly pointing it out. |
Still not clear on how to resolve this, have gone thru both of your answers in detail -- as you said yourself, @JonWallsten:
I need to use typescript version 2.7.2. @DcsMarcRemolt, you patched some newer version (master branch), and not sure how to even use the compiled Some other questions: So yeah, obviously I'm not |
And are you then:
(P.S. - guys, try to sympathize, I'm rebuilding my I know typescript isn't your responsibility! |
Tested with Typescript 2.7.2: Open node_modules/typescript/lib/typescript.js (the compiled source in your project) Search for "Host should not return a redirect source file from Directly before this line (the assert) insert:
Start AOT dev build, change sth, watch the error. |
@JonWallsten tried applying your patch, but it just substitutes one error for another. Now I get the following when I make a change in watch mode:
|
I've asked the team to consider re-triaging this issue and raising the priority after reading the ngx-bootstrap post on upgrading to Ivy. |
…uld not return a redirect source file from `getSourceFile`' error to be shown. This is fixed by not returning the redirected file, but rather the target of the redirect. Closes angular#22524
…s `getSourceFile` Closes angular#22524
…s from `getSourceFile` Closes angular#22524
…s from `getSourceFile` Closes angular#22524
…ourceFile from getSourceFile Closes angular#22524
…ourceFile from getSourceFile Closes angular#22524
…ourceFile from getSourceFile Closes angular#22524
…ourceFile from getSourceFile Closes angular#22524
…ourceFile from getSourceFile Closes angular#22524
…ourceFile from getSourceFile Closes angular#22524
…ourceFile from getSourceFile Closes angular#22524
…ourceFile from getSourceFile Closes angular#22524
…ourceFile from getSourceFile Closes angular#22524
…ourceFile from getSourceFile Closes angular#22524
Thanks to this great pointer from @DcsMarcRemolt, I was able to find our offending code that lead to this error. In ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`") to: ts.Debug.assert(
!newSourceFile.redirectInfo,
"Host should not return a redirect source file from `getSourceFile`",
() => `Duplicate .d.ts files: ${newSourceFile.fileName} <-> ${newSourceFile.redirectInfo.redirectTarget.fileName}`
); And then got the error like:
Which I found odd, so I searched our code base for: A bit unfortunate that such a small typo can cause such an obscure error that lead to hours of debugging, but, oh well... it happens. Hope this helps someone else! |
Just wanted to let you know that the PR for this issue is done. We're waiting for the code owner to be back and then approve. So hopefully in a short time we just leave this thread behind us! |
So... this was only released for Angular 8? So anyone on Angular 7, which was released less than a year ago is SOL? EDIT: I just realized my project is on Angular 6, so a more productive question from me would be, will this fix be present in 6? Or any other older versions of Angular? |
Well, why can’t you upgrade? |
tens of thousands of lines of code and it isn't even my project, im like a guest in the project (but i heavily need the project to work effectively for my own sister project). |
Upgrading from v6 or 7 is nearly automatic. Maybe a day of compile errors to fix. Worth it imo. |
@Bjeaurn Look at Mr Fancypants over here with the spare day to spend fixing compile errors for a framework upgrade! ;) |
Short answer to your initial question: no. No backwards updates. The timeline clearly says we move forward. Breaking changes every major, etc. Basic semver. If you’re stuck in v6 and you can’t upgrade “cause a day”, I really feel for you and your team. Someone needs to tell management or the PO that this will save you days when 9 comes out. Or weeks when 10 comes out. GL HF. Let me know if you want external help, I’ll be happy to accommodate you. |
…ourceFile from getSourceFile (angular#26036) Closes angular#22524 PR Close angular#26036
Nothing to add as the issue has already been fixed in later update, but I've found a reliable work-around for my situation, and perhaps others that aren't able to upgrade at the moment, to at least keep the webpack dev server watching:
If you save anything other than a You should end up with a sequence similar to this:
|
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. |
I'm submitting a...
Current behavior
When using webpack-dev-server in --watch mode and you make a change the build process throws the following error:
Expected behavior
It should not throw an error and compile the code as usual.
Minimal reproduction of the problem with instructions
See this PR for more info: ng-packagr/ng-packagr#637
What is the motivation / use case for changing the behavior?
Webback watch mode is useless if you have to restart it after each change.
Environment
Conclusion
This seems to work. Not sure what else it will break though.
Added the redirectInfo fix from the PR i referenced.
Edit: It seems like my ticket is not clear enough in pointing out the issue based on the new posts in this thread.
The issue happens due to identical *.d.ts file found via two paths in the compilation.
In plain english: The packages uses the same dependency that includes a definition file.
The text was updated successfully, but these errors were encountered: