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
feat(ngcc): execute schematic-like migrations in ngcc #33279
Commits on Oct 23, 2019
-
fix(ngcc): prevent reflected decorators from being clobbered
ngcc has an internal cache of computed decorator information for reflected classes, which could previously be mutated by consumers of the reflection host. With the ability to inject synthesized decorators, such decorators would inadvertently be added into the array of decorators that was owned by the internal cache of the reflection host, incorrectly resulting in synthesized decorators to be considered real decorators on a class. This commit fixes the issue by cloning the cached array before returning it.
Configuration menu - View commit details
-
Copy full SHA for 73437e7 - Browse repository at this point
Copy the full SHA 73437e7View commit details -
Configuration menu - View commit details
-
Copy full SHA for fd8b1a8 - Browse repository at this point
Copy the full SHA fd8b1a8View commit details -
feat(ngcc): migrate services that are missing
@Injectable()
A class that is provided as Angular service is required to have an `@Injectable()` decorator so that the compiler generates its injectable definition for the runtime. Applications are automatically migrated using the "missing-injectable" schematic, however libraries built for older version of Angular may not yet satisfy this requirement. This commit ports the "missing-injectable" schematic to a migration that is ran when ngcc is processing a library. This ensures that any service that is provided from an NgModule or Directive/Component will have an `@Injectable()` decorator.
Configuration menu - View commit details
-
Copy full SHA for 9642f89 - Browse repository at this point
Copy the full SHA 9642f89View commit details -
Configuration menu - View commit details
-
Copy full SHA for be384d1 - Browse repository at this point
Copy the full SHA be384d1View commit details -
refactor(ivy): mark synthetic decorators explicitly
In ngcc's migration system, synthetic decorators can be injected into a compilation to ensure that certain classes are compiled with Angular logic, where the original library code did not include the necessary decorators. Prior to this change, synthesized decorators would have a fake AST structure as associated node and a made-up identifier. In theory, this may introduce issues downstream: 1) a decorator's node is used for diagnostics, so it must have position information. Having fake AST nodes without a position is therefore a problem. Note that this is currently not a problem in practice, as injected synthesized decorators would not produce any diagnostics. 2) the decorator's identifier should refer to an imported symbol. Therefore, it is required that the symbol is actually imported. Moreover, bundle formats such as UMD and CommonJS use namespaces for imports, so a bare `ts.Identifier` would not be suitable to use as identifier. This was also not a problem in practice, as the identifier is only used in the `setClassMetadata` generated code, which is omitted for synthetically injected decorators. To remedy these potential issues, this commit makes a decorator's identifier optional and switches its node over from a fake AST structure to the class' name.
Configuration menu - View commit details
-
Copy full SHA for 72882c4 - Browse repository at this point
Copy the full SHA 72882c4View commit details -
refactor(ngcc): rework undecorated parent migration
Previously, the (currently disabled) undecorated parent migration in ngcc would produce errors when a base class could not be determined statically or when a class extends from a class in another package. This is not ideal, as it would cause the library to fail compilation without a workaround, whereas those problems are not guaranteed to cause issues. Additionally, inheritance chains were not handled. This commit reworks the migration to address these limitations.
Configuration menu - View commit details
-
Copy full SHA for 7960f91 - Browse repository at this point
Copy the full SHA 7960f91View commit details -
Configuration menu - View commit details
-
Copy full SHA for 72b67d6 - Browse repository at this point
Copy the full SHA 72b67d6View commit details -
feat(ngcc): enable migrations to apply schematics to libraries
When upgrading an Angular application to a new version using the Angular CLI, built-in schematics are being run to update user code from deprecated patterns to the new way of working. For libraries that have been built for older versions of Angular however, such schematics have not been executed which means that deprecated code patterns may still be present, potentially resulting in incorrect behavior. Some of the logic of schematics has been ported over to ngcc migrations, which are automatically run on libraries. These migrations achieve the same goal of the regular schematics, but operating on published library sources instead of used code.
Configuration menu - View commit details
-
Copy full SHA for ebf596c - Browse repository at this point
Copy the full SHA ebf596cView commit details