question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot use ts_library with angular plugin with Angular v10

See original GitHub issue

🐞 bug report

Affected Package

@angular/bazel

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)

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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
IgorMinarcommented, Jun 24, 2020

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.

0reactions
angular-automatic-lock-bot[bot]commented, Aug 4, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular 10 error "Cannot find module '@angular/core' or its ...
Everything worked fine, but i decided to upgrade angular and angular material to v 10, because I needed a date range picker and...
Read more >
Angular package format
This document describes the Angular Package Format (APF). APF is an Angular specific specification for the structure and format of npm packages that...
Read more >
Setup for upgrading from AngularJS
Install the latest versions of the Angular framework packages by running: Β· Install the latest versions of other packages used by Angular (RxJS,...
Read more >
Upgrading from AngularJS to Angular
Correspondingly, when you upgrade an AngularJS component and use it from Angular, all the bindings defined for scope (or bindToController ) of the...
Read more >
Usage of Angular libraries published to npm
To integrate reusable library code into an application, you need to install the package and import the provided functionality in the location you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found