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

WIP: initial version of ng_package #21431

Closed
wants to merge 24 commits into from

Conversation

IgorMinar
Copy link
Contributor

No description provided.

@mary-poppins
Copy link

You can preview 4cec674 at https://pr21431-4cec674.ngbuilds.io/.

@mary-poppins
Copy link

You can preview 774d202 at https://pr21431-774d202.ngbuilds.io/.

@mary-poppins
Copy link

You can preview e6e595a at https://pr21431-e6e595a.ngbuilds.io/.

@mary-poppins
Copy link

You can preview ea7ede6 at https://pr21431-ea7ede6.ngbuilds.io/.

@IgorMinar
Copy link
Contributor Author

@alexeagle I pulled your branch, yarn installed and bazel build and then get this error because I yarn installed in the aio/ dir and not in the root:

$ bazel build //packages/core:package
INFO: Analysed target //packages/core:package (0 packages loaded).
INFO: Found 1 target...
ERROR: /private/var/tmp/_bazel_iminar/9b8801a4939e9750a817dc0cb35bbbca/external/angular/src/packager/BUILD.bazel:4:1: Compiling TypeScript (devmode) @angular//src/packager:lib failed (Exit 1)
external/angular/src/packager/index.ts(1,22): error TS7016: Could not find a declaration file for module 'shelljs'. '/private/var/tmp/_bazel_iminar/9b8801a4939e9750a817dc0cb35bbbca/execroot/angular_src/node_modules/shelljs/shell.js' implicitly has an 'any' type.
external/angular/src/packager/index.ts(16,12): error TS7006: Parameter 'f' implicitly has an 'any' type.
external/angular/src/packager/index.ts(23,41): error TS7006: Parameter 'f' implicitly has an 'any' type.

Target //packages/core:package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 3.259s, Critical Path: 2.59s
FAILED: Build did NOT complete successfully

This sounds like a trap, especially for those that manage yarn dependencies and switch branches. Could we have bazel run yarn install or verify automatically?

@kara kara added the area: build & ci Related the build and CI infrastructure of the project label Jan 10, 2018
@alexeagle
Copy link
Contributor

alexeagle commented Jan 10, 2018 via email

@IgorMinar IgorMinar added the action: merge The PR is ready for merge by the caretaker label Jan 12, 2018
@ngbot
Copy link

ngbot bot commented Jan 12, 2018

I see that you just added the PR action: merge label. It won't do anything good though, because the following checks are still failing:

  • conflicts with base branch "master"
  • missing required label: "PR target:"
  • statuses failing/pending (ci/circleci: lint, continuous-integration/travis-ci/pr, code-review/pullapprove)

If you want your PR to be merged, it has to pass all the checks. But if you have a good reason to want to merge this, please contact the caretaker to let them know.

@IgorMinar IgorMinar removed the action: merge The PR is ready for merge by the caretaker label Jan 12, 2018
inputs = collect_es6_sources(ctx).to_list(),
executable = ctx.executable._rollup,
arguments = [
# TODO(i): how to get this path in a proper way?!?!?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexeagle can you please advise?

license_banner = ''
if (license_banner_file != None):
# TODO(i): read the file to string for realzzz!!!!
license_banner = str(license_banner_file);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexeagle how does one read contents of a file? is that even possible? I'm guessing that the file doesn't even exist yet when this code is executing, but there surely must be a way to read a text file into a string.. no?

or is my only option to create a shell script or nodejs binary and read the file there?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ctx.actions.template_file or so

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant https://docs.bazel.build/versions/master/skylark/lib/actions.html#expand_template but the problem with that is that the output is a File not a string. I think what I was trying to do is fundamentally incompatible with how bazel works - I can't read a file within the code of an action. I have to write an executable to do that or use a run_shell instead. I'll try run_shell first.

outs = ["%s_package.stamped.json" % name],
stamp = True,
cmd = "sed \"s/0.0.0-PLACEHOLDER/$$(grep BUILD_SCM_HASH bazel-out/volatile-status.txt | cut -d' ' -f 2)/\" $< > $@",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uhh.. this seems gross. isn't there a better way to do this?

# TODO(i): move ng_package with all tests and source code into a separate directory within packages/bazel
# this will require:
# - moving things around within packages/bazel/src
# - getting rid of the nested workspace so that we can use //packages/core:package to test against
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not necessarily, the workspaces are peers. From packages/bazel you can depend on @angular_src// - we already do this so that the ng_module implementation can reference compiler-cli

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that but got weird errors from within the label (I was able to invoke the label, but the label failed to execute when invoked in this way - I didn't debug it)

srcs = glob(["*.ts"]),
tsconfig = ":tsconfig.json",
# TODO(i): this doesn't work - I can't seem to be able to reference this label..
# Maybe it's because the npm_install happens via the weird WORKSPACE setup function?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it @bazel_ng_package_deps//... ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why @? I'd expect it to be @angular_src//:bazel_ng_package_deps or :bazel_ng_package_deps. are all labels created via WORKSPACE prefixed with @ or what?

)

ng_package_entry_point(
name = "http",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all this repetition sucks. can't we just provide the map once as the union of all these entries?
If we need to trim it for each entry point, can't we do this in the action?
then we don't need ng_package_entry_point rule

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. I'm not happy about it. this is already way better than what Chuck had in his branch. +1 for streamlining this more.

@@ -1,8 +1,8 @@
package(default_visibility = ["//visibility:public"])

load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("@angular//:index.bzl", "ng_module")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should generally load from //tools:defaults.bzl so everything in the repo is built with the one tsconfig the editor sees

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh. I need to rebase to get defaults.bzl

# Release support #
###############################

build --workspace_status_command=./tools/bazel_stamp_vars.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note for me: we need to test with --nostamp to make sure it doesn't blow up

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain?

@angular angular deleted a comment from ngbot bot Jan 16, 2018
@angular angular deleted a comment from ngbot bot Jan 16, 2018
@mary-poppins
Copy link

You can preview b350a6e at https://pr21431-b350a6e.ngbuilds.io/.

@mary-poppins
Copy link

You can preview 80f71f7 at https://pr21431-80f71f7.ngbuilds.io/.

@mary-poppins
Copy link

You can preview 8288bdf at https://pr21431-8288bdf.ngbuilds.io/.

@mary-poppins
Copy link

You can preview d266b67 at https://pr21431-d266b67.ngbuilds.io/.

@IgorMinar
Copy link
Contributor Author

IgorMinar commented Jan 21, 2018

the esm5 build fails with:

21:25 $ bazel build //packages/core:package
INFO: Analysed target //packages/core:package (33 packages loaded).
INFO: Found 1 target...
INFO: From Angular Packaging: rolling up package:

bazel-out/darwin-fastbuild/bin/packages/core/package.es6/packages/core/testing/index.js → bazel-out/darwin-fastbuild/bin/packages/core/fesm2015-testing/testing.js...
created bazel-out/darwin-fastbuild/bin/packages/core/fesm2015-testing/testing.js in 286ms
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/index.ngfactory.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/index.ngsummary.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/index.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/public_api.ngfactory.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/public_api.ngsummary.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/public_api.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/async.ngfactory.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/async.ngsummary.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/async.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/async_test_completer.ngfactory.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/async_test_completer.ngsummary.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/async_test_completer.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/before_each.ngfactory.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/before_each.ngsummary.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/before_each.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/component_fixture.ngfactory.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/component_fixture.ngsummary.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/component_fixture.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/fake_async.ngfactory.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/fake_async.ngsummary.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/fake_async.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/lang_utils.ngfactory.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/lang_utils.ngsummary.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/lang_utils.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/logger.ngfactory.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/logger.ngsummary.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/logger.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/metadata_override.ngfactory.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/metadata_override.ngsummary.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/metadata_override.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/ng_zone_mock.ngfactory.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/ng_zone_mock.ngsummary.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/ng_zone_mock.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/private_export_testing.ngfactory.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/private_export_testing.ngsummary.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/private_export_testing.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/test_bed.ngfactory.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/test_bed.ngsummary.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/test_bed.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/test_compiler.ngfactory.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/test_compiler.ngsummary.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/test_compiler.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/testing.ngfactory.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/testing.ngsummary.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/testing.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/testing_internal.ngfactory.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/testing_internal.ngsummary.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: output 'packages/core/testing/testing.es5_esm/packages/core/testing/src/testing_internal.js' was not created
ERROR: /Users/iminar/Dev/angular/packages/core/testing/BUILD.bazel:5:1: not all outputs were created or valid
Target //packages/core:package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 49.774s, Critical Path: 42.95s
FAILED: Build did NOT complete successfully

I haven't debugged this yet. I'll try tomorrow.

@alexeagle does this look familiar? your branch gave me the same error before I cherry-picked it over.

@ngbot
Copy link

ngbot bot commented Jan 24, 2018

Hi @IgorMinar! This PR has merge conflicts due to recent upstream merges.
Please help to unblock it by resolving these conflicts. Thanks!

@mary-poppins
Copy link

You can preview d673a71 at https://pr21431-d673a71.ngbuilds.io/.

@mary-poppins
Copy link

You can preview 96f6f2f at https://pr21431-96f6f2f.ngbuilds.io/.

@mary-poppins
Copy link

You can preview 080156b at https://pr21431-080156b.ngbuilds.io/.

@IgorMinar IgorMinar added the feature Issue that requests a new feature label Feb 9, 2018
@ngbot
Copy link

ngbot bot commented Feb 12, 2018

Hi @IgorMinar! This PR has merge conflicts due to recent upstream merges.
Please help to unblock it by resolving these conflicts. Thanks!

2 similar comments
@ngbot
Copy link

ngbot bot commented Feb 12, 2018

Hi @IgorMinar! This PR has merge conflicts due to recent upstream merges.
Please help to unblock it by resolving these conflicts. Thanks!

@ngbot
Copy link

ngbot bot commented Feb 12, 2018

Hi @IgorMinar! This PR has merge conflicts due to recent upstream merges.
Please help to unblock it by resolving these conflicts. Thanks!

@ngbot
Copy link

ngbot bot commented Feb 13, 2018

Hi @IgorMinar! This PR has merge conflicts due to recent upstream merges.
Please help to unblock it by resolving these conflicts. Thanks!

1 similar comment
@ngbot
Copy link

ngbot bot commented Feb 13, 2018

Hi @IgorMinar! This PR has merge conflicts due to recent upstream merges.
Please help to unblock it by resolving these conflicts. Thanks!

@alexeagle
Copy link
Contributor

landing a rebased subset of this in #22176

@alexeagle
Copy link
Contributor

Obsolete; ng_package landed a few releases ago

@alexeagle alexeagle closed this 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
area: build & ci Related the build and CI infrastructure of the project cla: yes feature Issue that requests a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants