Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Zone bazel#1232

Merged
alexeagle merged 1 commit intoangular:masterfrom
JiaLiPassion:zone-bazel
May 31, 2019
Merged

Zone bazel#1232
alexeagle merged 1 commit intoangular:masterfrom
JiaLiPassion:zone-bazel

Conversation

@JiaLiPassion
Copy link
Copy Markdown
Collaborator

Bazel rule for zone.js

@googlebot
Copy link
Copy Markdown

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

ℹ️ Googlers: Go here for more info.

1 similar comment
@googlebot
Copy link
Copy Markdown

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

ℹ️ Googlers: Go here for more info.

@googlebot
Copy link
Copy Markdown

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

ℹ️ Googlers: Go here for more info.

1 similar comment
@googlebot
Copy link
Copy Markdown

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

ℹ️ Googlers: Go here for more info.

Comment thread WORKSPACE Outdated
"@bazel/bazel",
"@bazel/ibazel",
"@bazel/buildifier",
# TODO: fails because it tries to install itself elsewhere on disk:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove unneeded comments

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done, thanks!

* found in the LICENSE file at https://angular.io/license
*/
!function(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict";
/**
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

seems like we should figure out how to avoid having the license duplicated? I suppose it compresses well...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The current zone.js bundles have the same issues, because inside the source code, we also have the license header, so I think we can resolve this issue later.

Comment thread lib/BUILD.bazel Outdated
package(default_visibility = ["//:__pkg__"])

exports_files([
"zone.ts",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

exposing sources outside the package is a smell, usually any rules using them should be declared here too. At least add a comment explaining why another package needs to be able to use these sources?
(the .ts files in particular seem wrong here, they should be compiled by a rule in this package)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This for test, I have removed it and will re-design when we figure out how to make karma for zone.js work.

Comment thread rollup.bzl Outdated
@@ -0,0 +1,12 @@
load("//lib:rollup.bzl", "rollup_bundle")
def rollup(bundles):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think the extra indirection to this file is useful, just inline this into the BUILD.bazel ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sure, you are right, I have removed all separated rollup.bzl and move the definition into BUILD.bazel.

Comment thread test/BUILD.bazel Outdated
],
srcs = glob([
"**/*.spec.ts",
"browser_entry_point.ts",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Once we move this to angular/angular, buildifier will warn that entries in a glob with no wildcard should be outside the glob
glob(["**/*.spec.ts"]) + ["browser-zone-setup.ts"]

Copy link
Copy Markdown
Collaborator Author

@JiaLiPassion JiaLiPassion May 14, 2019

Choose a reason for hiding this comment

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

Got it, I will modify this later, because currently this settings not work... I will delete all bazel settings of test for now. So this PR is only about npm_package.

Comment thread test/test.bzl Outdated
"test/main",
]

def get_web_test_deps():
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this isn't called anywhere yet?

We generally prefer to just expand this out into the BUILD file. It's a bit repetitive to have 5 ts_library targets with similar setup, however tooling like ts_auto_deps makes it manageable. By having this in a macro, tooling like buildozer will no longer be able to machine-edit the rules

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Got it, I will modify this later, because currently this settings not work... I will delete all bazel settings of test for now. So this PR is only about npm_package.

Comment thread BUILD.bazel
cmd = "cp $< $(@D)/zone_externs.js",
)

npm_package(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we should add an e2e test for the structure and content of the package so that the genrule spaghetti above can be safely refactored out.
something like https://github.com/angular/angular/blob/master/packages/bazel/test/ng_package/core_package.spec.ts maybe?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sure, got it, I have added test cases.

Comment thread BUILD.bazel Outdated
for b in ES2015_BUNDLES
]

# Extract and rename each es5 bundle to a .js and .min.js in the dist/ dir
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this seems wrong. If we want the artifacts to appear in the dist/ subfolder in the output tree (and therefore in the npm package) then we should probably have a BUILD file in dist/ in the source tree which declares them. then we don't have to move things around. I can do some refactoring to help with that.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Got it, I made it work, and testing it now.

@googlebot
Copy link
Copy Markdown

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

ℹ️ Googlers: Go here for more info.

1 similar comment
@googlebot
Copy link
Copy Markdown

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

ℹ️ Googlers: Go here for more info.

@JiaLiPassion JiaLiPassion force-pushed the zone-bazel branch 3 times, most recently from b363288 to 525ad67 Compare May 15, 2019 14:38
@googlebot
Copy link
Copy Markdown

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

1 similar comment
@googlebot
Copy link
Copy Markdown

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

Copy link
Copy Markdown
Contributor

@alexeagle alexeagle left a comment

Choose a reason for hiding this comment

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

Yay! this looks really good

Comment thread lib/BUILD.bazel Outdated
"closure/zone_externs.js",
])

filegroup(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think we need both the exports_files and the filegroup to expose the zone_externs.js file

Comment thread dist/zone.js.d.ts
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/// <amd-module name="__main__/lib/zone" />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is a bit gross, users don't want to see main - in angular we do something to trim these lines from published .d.ts

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Got it, could you show me the source that how angular trim those lines? Thanks

Comment thread BUILD.bazel Outdated
"package.json",
],
replacements = {
# Since the bazel package is experimental, patch the version number
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this seems like copy-paste - this isn't the bazel package

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

You are right, I removed this replacements.

Comment thread dist/BUILD.bazel

genrule(
name = "zone_d_ts",
srcs = ["//lib"],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this concatenating multiple .d.ts inputs into a single output? maybe we should use the api-extractor like we do in the angular repo.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This rule just copy the zone.d.ts from lib to dist/zone.js.d.ts, we only have one d.ts file here.

Comment thread dist/BUILD.bazel

# Extract and rename each es5 bundle to a .js and .min.js in the dist/ dir
[
genrule(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is pretty gross... maybe I can find a way to refactor it later

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

You are right, thanks!

Comment thread BUILD.bazel Outdated
srcs = [":npm_package_spec_lib"],
data = [
":npm_package",
"@npm//@types/shelljs",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think the typings are needed by the test, these would only be useful for a rule that does type-checking

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Got it, typings removed. thanks!

@JiaLiPassion
Copy link
Copy Markdown
Collaborator Author

angular/angular#30615 passed, so this PR should work fine at least in angular repo. Need to very it in G3 too.

@alexeagle alexeagle merged commit 71b9371 into angular:master May 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants