Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

ts_proto_library cannot be used by ng_package #211

Closed
Toxicable opened this issue Jun 4, 2018 · 8 comments
Closed

ts_proto_library cannot be used by ng_package #211

Toxicable opened this issue Jun 4, 2018 · 8 comments
Assignees
Labels

Comments

@Toxicable
Copy link
Contributor

This error is throw when using ts_proto_library as a dep on a ng_module that is being used by a ng_package.
The ng_module works fine but when it goes into ng_package it breaks.
ts_proto_library -> ng_module -> ng_package

reproduction here: angular/universal#1003

  • Clone and run bazel build modules/grpc-engine:npm_package

fabian@fabian-desktop:~/Documents/universal$ bazel build modules/grpc-engine:npm_package
ERROR: /home/fabian/Documents/universal/modules/grpc-engine/BUILD.bazel:13:1: in @angular//src:esm5.bzl%esm5_outputs_aspect aspect on ts_proto_library rule //modules/grpc-
engine:engine_ts_proto:
Traceback (most recent call last):
File "/home/fabian/Documents/universal/modules/grpc-engine/BUILD.bazel", line 13
@angular//src:esm5.bzl%esm5_outputs_aspect(...)
File "/home/fabian/.cache/bazel/_bazel_fabian/../external/angular/src/esm5.bzl", line 58, in _esm5_outputs_aspect
target.typescript.replay_params
'struct' object has no attribute 'replay_params'
Available attributes: declarations, es5_sources, es6_sources, transitive_declarations, transitive_es5_sources, transitive_es6_sources, type_blacklisted_declarations

@alexeagle
Copy link
Contributor

Oops yeah, we made the output of ts_proto_library conform to a subset of the providers you get from a ts_library, expecting it to be used only in ts_library - Greg we already have some helper like compile_ts that creates the providers, I think we should refactor a bit so we can reuse the helper and get a true ts_library output

@gregmagolan
Copy link
Contributor

I took at look at this issue and its non-trivial to fix as ng_package is expecting a replay_params in the TS provider so that it can re-run tsc and generate esm5. That doesn't make any sense to have in ts_proto_library since it doesn't run tsc.

Work-around for now could be to not generate esm5 outputs for targets that don't provide replay_params, which would mean the esm5 bundle would be missing the proto outputs. @Toxicable would that work for the time being?

Need to work with @alexeagle to figure out how to fix this properly so that we can get esm5 outputs out of ts_proto_library as well.

@Toxicable
Copy link
Contributor Author

@gregmagolan Sure I can give that a go, however im not really sure how to do it.
Would I have to do something like this:
https://github.com/bazelbuild/rules_typescript/blob/master/examples/es6_output/es6_consumer.bzl#L20
Then use it like proto_library -> ts_proto_library -> es6_consumer -> ng_module -> ng_package

@gregmagolan
Copy link
Contributor

gregmagolan commented Aug 15, 2018

@Toxicable I can make the change to rules_typescript to fix the build in the case of a TS provider not providing a replay_params. The downside being that the esm5 bundle would not have the proto files until we come up with a proper solution.

@Toxicable
Copy link
Contributor Author

@gregmagolan I think that would be good to at least unblock this issue for now.

@gregmagolan
Copy link
Contributor

angular/angular#25605 will unblock this issue.

Once that lands you'll also need "protobufjs": "5.0.0" in your package.json and

        "protobufjs",
        "bytebuffer",

in your //:node_modules filegroup

@gregmagolan
Copy link
Contributor

angular/angular#25648 landed on the 6.1.x branch. still waiting to land angular/angular#25605 on master.

@gregmagolan
Copy link
Contributor

Everything merged into to both master & the 6.1.x branch.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants