Skip to content

Cannot use ts_library with angular plugin with Angular v10 #37542

Closed

Description

@gregmagolan

🐞 bug report

Affected Package

@angular/bazel

Is this a regression?

Yes. This was not an issue with v9.

Description

Originally reported in rules_nodejs: bazel-contrib/rules_nodejs#1932. I'll summarize the the main points here.

@alan-agius4 did some preliminary analysis:

"This is the result that In version 10, incremental type-checking was introduced in Ivy, instead of a global type-checking file we now have a type-checking file for each file.

There are two problems here that I can see here.

In tsc_wrapped, the return of setupCompilation is ignored. https://github.com/bazelbuild/rules_typescript/blob/c4b325859b8d2c0579b094c67f449f1c3143271e/internal/tsc_wrapped/tsc_wrapped.ts#L389 This returns 2 pieces of information, files are shouldn't be emitted and files which shouldn't be checked for diagnostics. This will cause 2 extra files to be emitted for each original source file. myfile.ngtypecheck.d.ts and myfile.ngtypecheck.js.

In the TS source file, a triple-slash reference to the type-checking file is added, however this is not removed when emitting the DTS, this seems to be more of a bug in the plugin itself.

I am not sure if maybe the first issue should be handled directly by NG Compiler, maybe sometime similar to ngtsc.wrapHost, because I am seeing that anyone who uses the plugin API will need to filter out those files from being emitted.

I did create a reproduction without Bazel https://github.com/alan-agius4/ngtsc-plugin-demo."

"Indeed the fix itself needs to happen at a NG plugin level, Unless you want to add temporary patch in rules_typescript.

That said, it's not clear to me who will address point 1 in rules_typescript."

"Had a chat with Alex R, he mentioned that the plugin is still experimental/in development and is not production ready and not surprised at all that there are such issues since the plugin API itself is not complete (it’s about half way there) nor rigorously tested."

🔬 Minimal Reproduction

So far this is reproduced in a rules_nodejs PR: bazel-contrib/rules_nodejs#1932

Its a bit tricky to run in there so I'll post a minimal repo with Bazel here if needed. @alan-agius4 created a reproduction without bazel: https://github.com/alan-agius4/ngtsc-plugin-demo

https://stackblitz.com/...

🔥 Exception or Error

Build failure looks like:

ERROR: /tmp/tmp-22174n75NHN2Y0PMq/src/app/hello-world/BUILD.bazel:13:1: Compiling TypeScript (devmode) //src/app/hello-world:hello-world failed (Exit 1)
Compilation failed Error: ENOENT: no such file or directory, open '/home/circleci/.cache/bazel/_bazel_circleci/b1ab2e3961386d73dc7e7e5b030b84bc/execroot/examples_angular/bazel-out/k8-fastbuild/bin/src/shared/material/material.module.ngtypecheck.d.ts'
    at Object.openSync (fs.js:440:3)
    at Object.readFileSync (fs.js:342:35)
    at CachedFileLoader.loadFile (/home/circleci/.cache/bazel/_bazel_circleci/b1ab2e3961386d73dc7e7e5b030b84bc/execroot/examples_angular/bazel-out/host/bin/tools/tsc_wrapped_with_angular.sh.runfiles/npm/node_modules/@bazel/typescript/internal/tsc_wrapped/cache.js:317:35)
    at /home/circleci/.cache/bazel/_bazel_circleci/b1ab2e3961386d73dc7e7e5b030b84bc/execroot/examples_angular/bazel-out/host/bin/tools/tsc_wrapped_with_angular.sh.runfiles/npm/node_modules/@bazel/typescript/internal/tsc_wrapped/compiler_host.js:367:40
    at Object.wrap (/home/circleci/.cache/bazel/_bazel_circleci/b1ab2e3961386d73dc7e7e5b030b84bc/execroot/examples_angular/bazel-out/host/bin/tools/tsc_wrapped_with_angular.sh.runfiles/npm/node_modules/@bazel/typescript/internal/tsc_wrapped/perf_trace.js:35:16)
    at CompilerHost.getSourceFile (/home/circleci/.cache/bazel/_bazel_circleci/b1ab2e3961386d73dc7e7e5b030b84bc/execroot/examples_angular/bazel-out/host/bin/tools/tsc_wrapped_with_angular.sh.runfiles/npm/node_modules/@bazel/typescript/internal/tsc_wrapped/compiler_host.js:366:26)
    at NgCompilerHost.getSourceFile (/home/circleci/.cache/bazel/_bazel_circleci/b1ab2e3961386d73dc7e7e5b030b84bc/execroot/examples_angular/bazel-out/host/bin/tools/tsc_wrapped_with_angular.sh.runfiles/npm/node_modules/@angular/compiler-cli/src/ngtsc/core/src/host.js:224:36)
    at findSourceFile (/home/circleci/.cache/bazel/_bazel_circleci/b1ab2e3961386d73dc7e7e5b030b84bc/execroot/examples_angular/bazel-out/host/bin/tools/tsc_wrapped_with_angular.sh.runfiles/npm/node_modules/typescript/lib/typescript.js:101515:29)
    at /home/circleci/.cache/bazel/_bazel_circleci/b1ab2e3961386d73dc7e7e5b030b84bc/execroot/examples_angular/bazel-out/host/bin/tools/tsc_wrapped_with_angular.sh.runfiles/npm/node_modules/typescript/lib/typescript.js:101392:85
    at getSourceFileFromReferenceWorker (/home/circleci/.cache/bazel/_bazel_circleci/b1ab2e3961386d73dc7e7e5b030b84bc/execroot/examples_angular/bazel-out/host/bin/tools/tsc_wrapped_with_angular.sh.runfiles/npm/node_modules/typescript/lib/typescript.js:101359:34)
ERROR: /tmp/tmp-22174n75NHN2Y0PMq/e2e/BUILD.bazel:23:1 Compiling TypeScript (devmode) //src/app/hello-world:hello-world failed (Exit 1)

from https://app.circleci.com/pipelines/github/bazelbuild/rules_nodejs/1075/workflows/44b8bb69-cf11-498c-828a-94c5cdb23ad8/jobs/44774/steps

🌍 Your Environment

Angular Version:

This applies to ts_library with angular plugin with Angular v10

Anything else relevant?

This would be breaking for users on upgrade to v10 that have opted in to Bazel as ng_module rule is going unsupported in Angular 10, and the examples in rules_nodejs for Angular have stopped using the @angular/bazel package.

Activity

  1. gregmagolan commented on Jun 11, 2020

    @gregmagolan
    ContributorAuthor
  2. added
    area: bazelIssues related to the published `@angular/bazel` build rules
    on Jun 11, 2020
  3. added this to the needsTriage milestone on Jun 11, 2020
  4. alxhub commented on Jun 15, 2020

    @alxhub
    Member

    This is a trivial issue to fix: NgTscPlugin does not currently call NgCompilerHost.postProgramCreationCleanup(), which was overlooked when
    that method was introduced in the refactoring commit 4213e8d.

  5. added
    regressionIndicates than the issue relates to something that worked in a previous version
    on Jun 24, 2020
  6. IgorMinar commented on Jun 24, 2020

    @IgorMinar
    Contributor

    Severity justification: I'm marking this as a regression even though one could argue that this since this is not a public api yet it shouldn't be marked as such. It's however important to recognize that this used to work and enabled "ngc as tsc plugin" integration in bazel that bazel/rules_nodejs started relying upon. We are interested in supporting this integration as it's important to get it into google3 as well as the CLI, so fixing this should be a priority comparable to treating regressions.

  7. JoostK commented on Jun 28, 2020

    @JoostK
    Member

    A fix for this issue (#37690) has been released in 10.0.1, so this should have been resolved.

  8. JoostK commented on Jul 4, 2020

    @JoostK
    Member

    Closing as resolved in #37690 in 10.0.1.

  9. angular-automatic-lock-bot commented on Aug 4, 2020

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  10. locked and limited conversation to collaborators on Aug 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: bazelIssues related to the published `@angular/bazel` build rulesarea: compilerIssues related to `ngc`, Angular's template compilerregressionIndicates than the issue relates to something that worked in a previous versiontype: bug/fix

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions