Cannot use ts_library with angular plugin with Angular v10
See original GitHub issueπ bug report
Affected Package
Is this a regression?
Yes. This was not an issue with v9.
Description
Originally reported in rules_nodejs: https://github.com/bazelbuild/rules_nodejs/pull/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: https://github.com/bazelbuild/rules_nodejs/pull/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)
π 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.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (5 by maintainers)
Top GitHub Comments
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.
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.