Repository navigation
Fix g3 core imports - #27998
Fix g3 core imports#27998alxhub wants to merge 2 commits into
Conversation
|
You can preview 0f8b677 at https://pr27998-0f8b677.ngbuilds.io/. |
0f8b677 to
317e2e4
Compare
317e2e4 to
525cdfb
Compare
|
You can preview 317e2e4 at https://pr27998-317e2e4.ngbuilds.io/. |
|
You can preview 525cdfb at https://pr27998-525cdfb.ngbuilds.io/. |
|
Nice work! I can't properly review from my phone (on holiday this week) but I have one request: could you update the comment in |
525cdfb to
15eaf33
Compare
|
@JoostK nice catch, done! |
|
You can preview 15eaf33 at https://pr27998-15eaf33.ngbuilds.io/. |
c3c77a5 to
e2b7501
Compare
|
You can preview c3c77a5 at https://pr27998-c3c77a5.ngbuilds.io/. |
|
You can preview e2b7501 at https://pr27998-e2b7501.ngbuilds.io/. |
petebacondarwin
left a comment
There was a problem hiding this comment.
From an ngcc point-of-view this looks like a really nice code tidy-up. A couple of minor nits.
e2b7501 to
3fc9187
Compare
|
You can preview 3fc9187 at https://pr27998-3fc9187.ngbuilds.io/. |
There was a problem hiding this comment.
Isn't importRewriter always defined?
There was a problem hiding this comment.
coreImportsFrom does no longer exist.
There was a problem hiding this comment.
No empty line between methods 😞
Currently the ImportManager class handles various rewriting actions of imports when compiling @angular/core. This is required as code compiled within @angular/core cannot import from '@angular/core'. To work around this, imports are rewritten to get core symbols from a particular file, r3_symbols.ts. In this refactoring, this rewriting logic is moved out of the ImportManager and put behind an interface, ImportRewriter. There are three implementers of the interface: * NoopImportRewriter, used for compiling all non-core packages. * R3SymbolsImportRewriter, used when ngtsc compiles @angular/core. * NgccFlatImportRewriter, used when ngcc compiles @angular/core (special logic is needed because ngcc has to rewrite imports in flat bundles differently than in non-flat bundles). This is a precursor to using this rewriting logic in other contexts besides the ImportManager.
Generated factory shims can import from @angular/core. However, we have special logic in place to rewrite self-imports when generating code for @angular/core. This commit leverages the new standalone ImportRewriter interface to properly rewrite imports in generated factory shims. Before this fix, a generated factory file for core would look like: ```typescript import * as i0 from './r3_symbols'; export var ApplicationModuleNgFactory = new ɵNgModuleFactory(...); ``` This is invalid, as ɵNgModuleFactory is just NgModuleFactory when imported via r3_symbols. FW-881 #resolve
3fc9187 to
cfb588d
Compare
|
You can preview cfb588d at https://pr27998-cfb588d.ngbuilds.io/. |
|
|
AndrewKushnir
left a comment
There was a problem hiding this comment.
Looks good, one nit is the way we work with '@angular/core': in some places we put it in a const and reference it, in other places, we just use this as a string to compare with a given value. We should probably unify that at some point (I noticed that in other places as well). This is a minor thing and definitely not a blocker to approve this PR :)
Generated factory shims can import from @angular/core. However, we have special logic in place to rewrite self-imports when generating code for @angular/core. This commit leverages the new standalone ImportRewriter interface to properly rewrite imports in generated factory shims. Before this fix, a generated factory file for core would look like: ```typescript import * as i0 from './r3_symbols'; export var ApplicationModuleNgFactory = new ɵNgModuleFactory(...); ``` This is invalid, as ɵNgModuleFactory is just NgModuleFactory when imported via r3_symbols. FW-881 #resolve PR Close #27998
|
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. |
Based on #27743 (for now)