Skip to content
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(bazel): transform generated shims (in Ivy) with tsickle #35848

Closed
wants to merge 1 commit into from

Commits on Mar 6, 2020

  1. feat(bazel): transform generated shims (in Ivy) with tsickle

    Currently, when Angular code is built with Bazel and with Ivy, generated
    factory shims (.ngfactory files) are not processed via the majority of
    tsickle's transforms. This is a subtle effect of the build infrastructure,
    but it boils down to a TsickleHost method `shouldSkipTsickleProcessing`.
    
    For ngc_wrapped builds (Bazel + Angular), this method is defined in the
    `@bazel/typescript` (aka bazel rules_typescript) implementation of
    `CompilerHost`. The default behavior is to skip tsickle processing for files
    which are not present in the original `srcs[]` of the build rule. In
    Angular's case, this includes all generated shim files.
    
    For View Engine factories this is probably desirable as they're quite
    complex and they've never been tested with tsickle. Ivy factories however
    are smaller and very straightforward, and it makes sense to treat them like
    any other output.
    
    This commit adjusts two independent implementations of
    `shouldSkipTsickleProcessing` to enable transformation of Ivy shims:
    
    * in `@angular/bazel` aka ngc_wrapped, the upstream `@bazel/typescript`
      `CompilerHost` is patched to treat .ngfactory files the same as their
      original source file, with respect to tsickle processing.
    
      It is currently not possible to test this change as we don't have any test
      that inspects tsickle output with bazel. It will be extensively tested in
      g3.
    
    * in `ngc`, Angular's own implementation is adjusted to allow for the
      processing of shims when compiling with Ivy. This enables a unit test to
      be written to validate the correct behavior of tsickle when given a host
      that's appropriately configured to process factory shims.
    
    For ngtsc-as-a-plugin, a similar fix will need to be submitted upstream in
    tsc_wrapped.
    alxhub committed Mar 6, 2020
    Configuration menu
    Copy the full SHA
    5ed75be View commit details
    Browse the repository at this point in the history