fix(ivy): prevent ngcc from referencing missing ɵsetClassMetadata#27055
fix(ivy): prevent ngcc from referencing missing ɵsetClassMetadata#27055JoostK wants to merge 4 commits into
Conversation
|
The source needs formatting: https://circleci.com/gh/angular/angular/104308 |
|
It seems that these changes are still not enough to fix the FESM5 situation. The ngcc-CLI integration test is complaining: https://circleci.com/gh/angular/angular/104316. |
|
I figured out why the integration test fails: The If I force the .d.ts transform to run for ESM2015 bundles, I do end up with a relative import but unfortunately that is of the form: Makes sense, given that the ESM2015 bundle path was used for searching for r3_symbols. For the Please mark this PR as WIP for now, I will try to resolve the above issue tomorrow evening. |
40dfdab to
50c4f02
Compare
|
Alright, I pushed a very dirty implementation to see if it would work, and it does. CircleCI isn't being triggered for some reason but I have seen the integration tests pass. The seconds commit needs some cleanup as it has currently gone wild. Also, tests are needed to verify that this works as expected. |
37a0a43 to
a1f1271
Compare
There was a problem hiding this comment.
Should this be exported from a utility class? Duplicating it already proved brittle
There was a problem hiding this comment.
I like the concept of an object to hold this stuff, I am not happy with the name though. Bundle is too generic.
Also I still switch back and forth between passing everything into the constructor versus passing everything to the renderProgram method versus (our current situation) of passing some things to each.
When ngtsc compiles @angular/core, it rewrites core imports to the r3_symbols.ts file that exposes all internal symbols under their external name. When creating the FESM bundle, the r3_symbols.ts file causes the external symbol names to be rewritten to their internal name. Under ngcc compilations of FESM bundles, the indirection of r3_symbols.ts is no longer in place such that the external names are retained in the bundle. Previously, the external name `ɵdefineNgModule` was explicitly declared internally to resolve this issue, but the recently added `setClassMetadata` was not declared as such, causing runtime errors. Instead of relying on the r3_symbols.ts file to perform the rewrite of the external modules to their internal variants, the translation is moved into the `ImportManager` during the compilation itself. This avoids the need for providing the external name manually.
a1f1271 to
789d323
Compare
|
@mhevery FYI, I'm planning on rebasing this on top of #26906 as it's quite conflicty, and @petebacondarwin's PR should be considered ahead of this one. |
|
And after a review from Alex R, I am currently rewriting some portion of that PR, but it should be ready in a few hours. |
| const isCore = entryPoint.name === '@angular/core'; | ||
| const r3SymbolsPath = isCore ? this.findR3SymbolsPath(dirname(entryPointFilePath)) : null; | ||
| const r3SymbolsPath = | ||
| isCore ? this.findR3SymbolsPath(dirname(entryPointFilePath), 'r3_symbols.js') : null; |
There was a problem hiding this comment.
Does this work even if we're compiling a FESM entrypoint?
There was a problem hiding this comment.
Yes. For FESMs, the NgccImportManager will prevent core imports from being generated if core itself is being compiled.
There was a problem hiding this comment.
Glad that is sorted :-)
|
@mhevery - can you review this for |
|
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. |
When ngtsc compiles @angular/core, it rewrites core imports to the
r3_symbols.ts file that exposes all internal symbols under their
external name. When creating the FESM bundle, the r3_symbols.ts file
causes the external symbol names to be rewritten to their internal name.
Under ngcc compilations of FESM bundles, the indirection of
r3_symbols.ts is no longer in place such that the external names are
retained in the bundle. Previously, the external name
ɵdefineNgModulewas explicitly declared internally to resolve this issue, but the
recently added
setClassMetadatawas not declared as such, causingruntime errors.
Instead of relying on the r3_symbols.ts file to perform the rewrite of
the external modules to their internal variants, the translation is
moved into the
ImportManagerduring the compilation itself. Thisavoids the need for providing the external name manually.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
ngcc compiled @angular/core would reference
setClassMetadataby its private nameɵsetClassMetadatawhich wouldn't be available during runtime.What is the new behavior?
External references are rewritten to their internal names during compilation, instead of relying on
r3_symbols.tsas that is not in use when ngcc processes the FESM bundles of @angular/core.Does this PR introduce a breaking change?
Other information