-
Notifications
You must be signed in to change notification settings - Fork 12k
Webpack watch with AOT, builds are inconsistent #12621
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
Comments
The AOT compiler actually performs some extra changes over the first few rebuilds as an rebuild optimization, so the However, you also mention That's a runtime error that only really happens when using upgrade. I've seen it before myself and it seems mostly a timing issue. It's tricky to have upgrade load at the right time. Right now I think this isn't really a bug in Angular CLI but actually related to ngUpgrade. @gkalpak @petebacondarwin WDYT? |
I doubt it is an ngUpgrade issue, since it works for some builds but not for others. AFAICT, the scripts are loaded through static imports, so the order should be deterministic, right? |
Something to keep in mind is that webpack will move all imports to the top of the file. If there is any side effect causing code in the original file before an import, it will be run after the import in the final bundle. |
Thanks, @filipesilva for looking into it. My issue is not the ngUpgrade error, but the fact that the first two builds differ from the third. Do you think the AOT optimizations could change the timing of the code in such a significant way? And thank you too, @clydin for pointing that out. However in the test repo, all the imports are at the top of the files. |
Unless you refer to e2e tests (where the nature of race conditions is different), I don't know what race conditions there could be with ngUpgrade 😕 |
@gkalpak this is the problem I was remembering: angular/angular#13060. It was a while ago. Details are fuzzy in my head 😄 |
@gkalpak I put the generated code in this gist: https://gist.github.com/henk23/0a3b2c77b12543f9934220bfbb0e5dfe/revisions Created: First build
Changes in line 6695 are mine. Changes in line 6659 are not. |
Interesting. The changes on line 6659 don't seem related to the actual changes on line 6695 (but I know very little about webpack internals). |
The line 6659 changes are part of how the AOT compiler changes some things around in the first few rebuilds. I tried following the repro and can confirm that after the second rebuild, all rebuilds will show the error below:
Further rebuilds always showed this error, and even fiddling with the timing of I'm not sure why this happens. But I can say If I had to bet, perhaps the AOT compiler breaks ngUpgrade when it does the rebuild optimizations. I think you should report this issue in https://github.com/angular/angular since that is where |
Hi all, it seems the reproduction provided in the original issue is no longer available. If the problem persists, please file a new issue and provide a new reproduction. Thanks. |
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
)Possibly related to #11835.
Command (mark with an
x
)Versions
node version: v8.12.0
npm version: 6.4.1
webpack version: 4.20.2
OS: macOS Sierra 10.12.6
Angular CLI: not used
Repro steps
npm install && node_modules/.bin/webpack -d -w
Ctrl+S
in any project file triggers 2nd build. Everything should still be fine.Ctrl+S
in any project file triggers 3rd build. There will be an error in the browser console now: "Error: AngularJS v1.x is not loaded!"The log given by the failure
There is no error in the build process. But you can see the line
in the output of the 3rd build which is unexpected since the module was not changed and the line does not appear in the 2nd build.
Desired functionality
The resulting app should be the same on every consecutive build.
Mention any other details that might be useful
Downgrading any of the dependencies to
6.1.1
or even6.0.0
as suggested in #11835 does not resolve the issue.The issue does not appear when using JIT with
skipCodeGeneration: true
in the AngularCompilerPlugin.The text was updated successfully, but these errors were encountered: