Closed
Description
I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
When using webpack-dev-server in --watch mode and you make a change the build process throws the following error:
ERROR in Error: Debug Failure. False expression: Host should not return a redirect source file from `getSourceFile`
at tryReuseStructureFromOldProgram (C:\Users\me\repo\web-app-angular\node_modules\typescript\lib\typescript.js:74285:26)
at Object.createProgram (C:\Users\me\repo\web-app-angular\node_modules\typescript\lib\typescript.js:73988:34)
at AngularCompilerProgram._updateProgramWithTypeCheckStubs (C:\Users\me\repo\web-app-angular\packages\compiler-cli\src\transformers\program.ts:508:26)
at C:\Users\me\repo\web-app-angular\packages\compiler-cli\src\transformers\program.ts:187:18
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
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
Angular version: 5.2.6 | 6.0.0-beta.6
For Tooling issues:
- Node version: 8.9.4
- Platform: Windows
Others:
Typescript: 2.6.2
Webpack: 4.0.1
Webpack-dev-server: 3.1.0
Conclusion
This seems to work. Not sure what else it will break though.
Added the redirectInfo fix from the PR i referenced.
// program.js:485 (compiled file)
tmpProgram.getSourceFiles().forEach(function (sf) {
if (_this.hostAdapter.isSourceFile(sf.fileName)) {
if (sf['redirectInfo']) {
sf = sf['redirectInfo'].redirectTarget;
}
sourceFiles.push(sf.fileName);
}
if (util_1.TS.test(sf.fileName) && !util_1.DTS.test(sf.fileName)) {
tsFiles.push(sf.fileName);
}
});
// program.ts:568 (source file)
// note: redirectInfo does not exists on ts.SourceFile hence the any.
tmpProgram.getSourceFiles().forEach(sf => {
if (this.hostAdapter.isSourceFile(sf.fileName)) {
if ((sf as any)['redirectInfo']) {
sf = (sf as any)['redirectInfo'].redirectTarget;
}
sourceFiles.push(sf.fileName);
}
if (TS.test(sf.fileName) && !DTS.test(sf.fileName)) {
tsFiles.push(sf.fileName);
}
});
console.log(sf.fileName);
console.log(sf['redirectInfo'].redirectTarget.fileName);
--------------------------
C:/Users/me/repo/web-app-angular/node_modules/@types/webpack/node_modules/source-map/source-map.d.ts
C:/Users/me/repo/web-app-angular/node_modules/@types/uglify-js/node_modules/source-map/source-map.d.ts
--------------------------
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.
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
DcsMarcRemolt commentedon Mar 2, 2018
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.
devoto13 commentedon Mar 2, 2018
Here is another reproduction using Angular CLI with linked dependencies and preliminary investigation of the problem:
kspearrin commentedon Apr 7, 2018
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.
JonWallsten commentedon Apr 7, 2018
@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.
kspearrin commentedon Apr 7, 2018
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
DcsMarcRemolt commentedon Apr 13, 2018
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!
samelliottdlt commentedon Apr 18, 2018
I was able to solve this issue by disabling AOT in ngtools/webpack 1.10.2 by setting the skipCodeGeneration option to true.
charlieargue commentedon Apr 18, 2018
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!
63 remaining items
fix(compiler-cli): Return original sourceFile instead of redirected s…
dtychshenko commentedon Jul 11, 2019
Thanks to this great pointer from @DcsMarcRemolt, I was able to find our offending code that lead to this error.
In
node_modules/typescript/lib/typescript.js
, I changed line:to:
And then got the error like:
Which I found odd, so I searched our code base for:
/Typeahead
with a case-sensitive flag, and, lo and behold, someone added an import likeimport { TypeaheadMatch } from 'ngx-bootstrap/Typeahead';
. After fixing the letter casing, the error was gone.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!
JonWallsten commentedon Jul 12, 2019
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!
fix(compiler-cli): Return original sourceFile instead of redirected s…
jmccarrell-lmi commentedon Aug 21, 2019
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?
Bjeaurn commentedon Aug 21, 2019
Well, why can’t you upgrade?
jmccarrell-lmi commentedon Aug 21, 2019
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).
Bjeaurn commentedon Aug 21, 2019
Upgrading from v6 or 7 is nearly automatic. Maybe a day of compile errors to fix. Worth it imo.
DanielSchaffer commentedon Aug 21, 2019
@Bjeaurn Look at Mr Fancypants over here with the spare day to spend fixing compile errors for a framework upgrade! ;)
Bjeaurn commentedon Aug 21, 2019
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.
fix(compiler-cli): Return original sourceFile instead of redirected s…
Rosseyn commentedon Sep 12, 2019
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:
ng serve
*.ts
file to trigger compile*.ts
file to recompile againng serve
If you save anything other than a
*.ts
file first, you'll end up in an unrecoverable compiler state until young serve
again. You don't need to save*.ts
file twice each time, just immediately after young serve
.You should end up with a sequence similar to this:
angular-automatic-lock-bot commentedon Oct 13, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.