Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bazel): correct expected outs for external sources in ng_module #22755

Conversation

gregmagolan
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[X] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] angular.io application / infrastructure changes
[ ] Other... Please describe:

What is the current behavior?

ng_module rule does not compute correct expected_outs for external repository sources.

Issue Number: #22613
(Note: this PR replaces #22659)

/cc @alexeagle

I tried adding a test for this but could not find a way to have a local_repository use the ng_module rule in the parent repository.

The failure can be reproduced on this branch of angular-bazel-example: https://github.com/gregmagolan/angular-bazel-example/tree/ng_module_module_name_bug

bazel run @yarn//:yarn
bazel build //src:src_with_ng_module

The failure seen is:

greg@Gregs-MacBook-Pro angular-bazel-example (ng_module_module_name_bug) $ bazel build //src:src_with_ng_module
Warning: failed to raise resource limit 8 to 524288: Invalid argument
.................
ERROR: /private/var/tmp/_bazel_greg/2c2a834fcea131eff2d962ffe20e1c87/external/external_rule/BUILD.bazel:15:1: in ng_module rule @external_rule//:ng_module: 
Traceback (most recent call last):
	File "/private/var/tmp/_bazel_greg/2c2a834fcea131eff2d962ffe20e1c87/external/external_rule/BUILD.bazel", line 15
		ng_module(name = 'ng_module')
	File "/private/var/tmp/_bazel_greg/2c2a834fcea131eff2d962ffe20e1c87/external/angular/src/ng_module.bzl", line 325, in _ng_module_impl
		ts_providers_dict_to_struct(ng_module_impl(ctx, compile_ts))
	File "/private/var/tmp/_bazel_greg/2c2a834fcea131eff2d962ffe20e1c87/external/angular/src/ng_module.bzl", line 325, in ts_providers_dict_to_struct
		ng_module_impl(ctx, compile_ts)
	File "/private/var/tmp/_bazel_greg/2c2a834fcea131eff2d962ffe20e1c87/external/angular/src/ng_module.bzl", line 300, in ng_module_impl
		ts_compile_actions(ctx, is_library = True, compile_acti..., <3 more arguments>)
	File "/private/var/tmp/_bazel_greg/2c2a834fcea131eff2d962ffe20e1c87/external/build_bazel_rules_typescript/internal/common/compilation.bzl", line 191, in ts_compile_actions
		outputs(ctx, ctx.label)
	File "/private/var/tmp/_bazel_greg/2c2a834fcea131eff2d962ffe20e1c87/external/angular/src/ng_module.bzl", line 242, in outputs
		_expected_outs(ctx)
	File "/private/var/tmp/_bazel_greg/2c2a834fcea131eff2d962ffe20e1c87/external/angular/src/ng_module.bzl", line 67, in _expected_outs
		ctx.new_file(ctx.bin_dir, (basename + ext))
external/external_rule/../external_rule/index.ngfactory.js
ERROR: Analysis of target '//src:src_with_ng_module' failed; build aborted: Analysis of target '@external_rule//:ng_module' failed; build aborted
INFO: Elapsed time: 31.525s
FAILED: Build did NOT complete successfully (27 packages loaded)

Notice that the expected out file for index.ts in the external_rule local_repository is external/external_rule/../external_rule/index.ngfactory.js. It should be external/external_rule/index.ngfactory.js.

What is the new behavior?

ng_module rule expected outs fixed to handle sources from external repository. If the source starts with .. then the external repository name is dropped. In the above example, the expected out is correctly resolved to external/external_rule/index.ngfactory.js.

Does this PR introduce a breaking change?

[ ] Yes
[X] No

Other information

@kara kara added the area: bazel Issues related to the published `@angular/bazel` build rules label Mar 14, 2018
@alexeagle alexeagle added target: patch This PR is targeted for the next patch release action: merge The PR is ready for merge by the caretaker labels Mar 19, 2018
@mhevery mhevery closed this in bfe077a Mar 19, 2018
@mhevery mhevery added target: major This PR is targeted for the next major release and removed target: patch This PR is targeted for the next patch release labels Mar 19, 2018
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: bazel Issues related to the published `@angular/bazel` build rules cla: yes target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants