components icon indicating copy to clipboard operation
components copied to clipboard

Compilation issues when using Angular Material 5.0.x/5.1.0 in an Angular/Bazel app

Open pshields opened this issue 8 years ago • 12 comments

Angular Material 5.1.0 (and 5.0.x) currently encounters compilation errors when consumed from an Angular/Bazel app.

An example error is Could not resolve ./index.ngfactory from [....]/angular_bazel_example/node_modules/@angular/material/button/typings/index.d.ts.

To reproduce, run bazel build //src from https://github.com/alexeagle/angular-bazel-example/pull/63 (small repro PR.)

I've confirmed that node_modules/@angular/material/button/typings/index.ngfactory.js is present, so I'm not sure why the import can't be resolved. The error is occurring in TsCompilerAotCompilerTypeCheckHostAdapter.fromSummaryFileName, which is defined in https://github.com/angular/angular/blob/5.2.x/packages/compiler-cli/src/transformers/compiler_host.ts. One guess I had is that the summary loader may be looking for a .ts file instead of a .js file, but I couldn't tell from looking at that file whether or not that is the case.

/cc @alexeagle @jelbourn

pshields avatar Jan 20 '18 20:01 pshields

@alexeagle we probably need to do something extra to make our packages bazel-friendly. It probably makes the most sense to wait until the ng_package rule is ready and just use that.

jelbourn avatar Jan 24 '18 22:01 jelbourn

It appears that index.ngfactory.js is not present in Bazel's sandbox dir in my case.

$ ls -lah /private/var/tmp/_bazel_adamyi/c6ce702e3f48b85fcb41d85f1378ee2d/bazel-sandbox/5702975849333547229/execroot/mpstar/node_modules/@angular/material/button/typings/
total 72
drwxr-xr-x  11 adamyi  wheel   374B Jan 29 22:04 .
drwxr-xr-x   7 adamyi  wheel   238B Jan 29 22:04 ..
lrwxr-xr-x   1 adamyi  wheel   144B Jan 29 22:04 button-module.d.ts -> /private/var/tmp/_bazel_adamyi/c6ce702e3f48b85fcb41d85f1378ee2d/execroot/mpstar/node_modules/@angular/material/button/typings/button-module.d.ts
lrwxr-xr-x   1 adamyi  wheel   154B Jan 29 22:04 button-module.ngsummary.json -> /private/var/tmp/_bazel_adamyi/c6ce702e3f48b85fcb41d85f1378ee2d/execroot/mpstar/node_modules/@angular/material/button/typings/button-module.ngsummary.json
lrwxr-xr-x   1 adamyi  wheel   137B Jan 29 22:04 button.d.ts -> /private/var/tmp/_bazel_adamyi/c6ce702e3f48b85fcb41d85f1378ee2d/execroot/mpstar/node_modules/@angular/material/button/typings/button.d.ts
lrwxr-xr-x   1 adamyi  wheel   147B Jan 29 22:04 button.ngsummary.json -> /private/var/tmp/_bazel_adamyi/c6ce702e3f48b85fcb41d85f1378ee2d/execroot/mpstar/node_modules/@angular/material/button/typings/button.ngsummary.json
lrwxr-xr-x   1 adamyi  wheel   136B Jan 29 22:04 index.d.ts -> /private/var/tmp/_bazel_adamyi/c6ce702e3f48b85fcb41d85f1378ee2d/execroot/mpstar/node_modules/@angular/material/button/typings/index.d.ts
lrwxr-xr-x   1 adamyi  wheel   145B Jan 29 22:04 index.metadata.json -> /private/var/tmp/_bazel_adamyi/c6ce702e3f48b85fcb41d85f1378ee2d/execroot/mpstar/node_modules/@angular/material/button/typings/index.metadata.json
lrwxr-xr-x   1 adamyi  wheel   146B Jan 29 22:04 index.ngsummary.json -> /private/var/tmp/_bazel_adamyi/c6ce702e3f48b85fcb41d85f1378ee2d/execroot/mpstar/node_modules/@angular/material/button/typings/index.ngsummary.json
lrwxr-xr-x   1 adamyi  wheel   141B Jan 29 22:04 public-api.d.ts -> /private/var/tmp/_bazel_adamyi/c6ce702e3f48b85fcb41d85f1378ee2d/execroot/mpstar/node_modules/@angular/material/button/typings/public-api.d.ts
lrwxr-xr-x   1 adamyi  wheel   151B Jan 29 22:04 public-api.ngsummary.json -> /private/var/tmp/_bazel_adamyi/c6ce702e3f48b85fcb41d85f1378ee2d/execroot/mpstar/node_modules/@angular/material/button/typings/public-api.ngsummary.json

$ ls -lah node_modules/@angular/material/button/typings/
total 240
drwxr-xr-x  13 adamyi  staff   442B Jan 29 22:04 .
drwxr-xr-x   7 adamyi  staff   238B Jan 29 21:54 ..
-rw-r--r--   1 adamyi  staff    41B Jan 18 08:38 button-module.d.ts
-rw-r--r--   1 adamyi  staff   187B Jan 29 21:54 button-module.ngsummary.json
-rw-r--r--   1 adamyi  staff   2.6K Jan 18 08:38 button.d.ts
-rw-r--r--   1 adamyi  staff   3.3K Jan 29 21:54 button.ngsummary.json
-rw-r--r--   1 adamyi  staff    78B Jan 18 08:38 index.d.ts
-rw-r--r--   1 adamyi  staff    18K Jan 18 08:38 index.metadata.json
-rw-r--r--   1 adamyi  staff    15K Jan 29 21:54 index.ngfactory.js
-rw-r--r--   1 adamyi  staff    25K Jan 29 22:04 index.ngsummary.json
-rw-r--r--   1 adamyi  staff   261B Jan 18 08:38 public-api.d.ts
-rw-r--r--   1 adamyi  staff   2.1K Jan 29 21:54 public-api.ngsummary.json

adamyi avatar Jan 29 '18 14:01 adamyi

https://github.com/angular/angular/blob/master/packages/bazel/src/ng_module.bzl#L195

This is fixed if I add *.ngfactory.js there (also in node_modules rule in Bazel file). However I don't know if this is the correct way to do this. If this is ok, I can send a PR there.

adamyi avatar Jan 29 '18 15:01 adamyi

In the bazel app, this has the same problem as https://github.com/alexeagle/angular-bazel-example/issues/56 for the devserver (but rollup and closure are fine). I think it's better to just use Bazel dependency to build material2.

adamyi avatar Jan 29 '18 16:01 adamyi

I know this is a work in progress, but is there an update to this issue or anything that I could do to help out (or work around)? This is the issue I am hitting while experimenting with Bazel building our application.

mattem avatar Feb 23 '18 16:02 mattem

We're still in the process of making out own build setup use bazel. There are unfortunately still a lot of issues to iron out.

jelbourn avatar Feb 23 '18 17:02 jelbourn

Any updates on this with https://github.com/alexeagle/angular-bazel-example/wiki/Publishing-Libraries in place? Material is one crucial thing blocking my team to switch to Bazel.

yamxun avatar Mar 12 '18 19:03 yamxun

We're still working on the bazel support overall

jelbourn avatar Mar 12 '18 22:03 jelbourn

@yamxun I think Angular v6 is a likely timeframe for this to land (early April) but we can't promise anything. Of course Angular material is one of the first libraries we'll expect to have working.

alexeagle avatar Mar 12 '18 23:03 alexeagle

Any update on this issue? This problem still exists in Angular 6.0.4.

ewhauser avatar Jul 04 '18 04:07 ewhauser

Any updates on this?

yamxun avatar Sep 25 '18 04:09 yamxun

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.