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

Add support for Label in nodejs_binary and rollup_bundle entry_point #777

Merged

Conversation

gregmagolan
Copy link
Collaborator

@gregmagolan gregmagolan commented May 22, 2019

Replaces #480

Closes #32

⚠️ Depends on upstream sass change: bazelbuild/rules_sass#87
⚠️ Depends on upstream rules_typescript change: bazelbuild/rules_typescript#453
⚠️ Depends on downstream angular-bazel-example change: angular/angular-bazel-example#450

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature (please, look at the "Scope of the project" section in the README.md file)
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

nodejs_binary#entry_point was a string.

What is the new behavior?

nodejs_binary#entry_point is now a Label.

Does this PR introduce a breaking change?

  • Yes
  • No

The entry_point accepts a target's name as an entry point. If the target is a rule, it should produce the JavaScript entry file that will be passed to the nodejs_binary rule). For example:

       filegroup(
           name = "entry_file",
           srcs = ["workspace/path/to/entry/file"]
       )
       nodejs_binary(
         name = "my_binary",
         ...
         entry_point = ":entry_file",
       )

If the entry JavaScript file belongs to the same package (as the BUILD file), you can simply reference it by its relative name to the package directory:

        nodejs_binary(
          name = "my_binary",
          ...
          entry_point = ":file.js",
        )

@googlebot
Copy link

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.

@gregmagolan gregmagolan force-pushed the sfeir-open-source/feat/entry-point branch 3 times, most recently from 04a575f to 9e0c317 Compare May 29, 2019 14:34
@gregmagolan gregmagolan force-pushed the sfeir-open-source/feat/entry-point branch 4 times, most recently from 2275c4d to 6cb6b07 Compare May 31, 2019 06:37
@gregmagolan gregmagolan force-pushed the sfeir-open-source/feat/entry-point branch 2 times, most recently from 47b7bd4 to b6efd59 Compare June 2, 2019 18:20
@gregmagolan gregmagolan force-pushed the sfeir-open-source/feat/entry-point branch from 936615d to 0a63964 Compare June 3, 2019 17:55
@gregmagolan gregmagolan requested a review from jbedard June 4, 2019 17:39
@gregmagolan gregmagolan changed the title Add support for Label in nodejs_binary#entry_point Add support for Label in nodejs_binary and rollup_bundle entry_point Jun 4, 2019
],
entry_point = "internal/e2e/rollup/foo.js",
srcs = ["bar.js"],
entry_point = ":foo.js",
Copy link
Collaborator

Choose a reason for hiding this comment

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

interesting that you don't have to specify foo.js in the srcs. It seems like it reduces one way users can fall off the happy path. on the other hand it means you have to consider entry_point when enumerating the inputs to a rule.
Should we give it more thought?

Copy link
Collaborator Author

@gregmagolan gregmagolan Jun 6, 2019

Choose a reason for hiding this comment

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

Hmmm. That's a good question. One strike against doing it this way is that if the user specifies :foo.ts as the entry_point they still have to add the ts_library :foo_lib to deps. I'm not sure what is best. On the other hand, the user adding :foo.js to entry_point and to srcs doesn't break anything with the current approach.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is some smell however with not having the file in srcs as seen here: https://github.com/bazelbuild/rules_nodejs/pull/777/files#diff-6e8a939ed5da5eca956cd2f53701b77e. Probably better to force it to be specified

internal/e2e/rollup_code_splitting/BUILD.bazel Outdated Show resolved Hide resolved
internal/jasmine_node_test/jasmine_node_test.bzl Outdated Show resolved Hide resolved
internal/node/node.bzl Outdated Show resolved Hide resolved
internal/node/node.bzl Outdated Show resolved Hide resolved
internal/node/node.bzl Outdated Show resolved Hide resolved
internal/rollup/rollup_bundle.bzl Outdated Show resolved Hide resolved
package.bzl Outdated Show resolved Hide resolved
packages/jasmine/test/BUILD.bazel Outdated Show resolved Hide resolved
packages/labs/webpack/src/cli.ts Outdated Show resolved Hide resolved
@gregmagolan gregmagolan force-pushed the sfeir-open-source/feat/entry-point branch 2 times, most recently from c849595 to 7220fbf Compare June 5, 2019 21:48
@gregmagolan gregmagolan force-pushed the sfeir-open-source/feat/entry-point branch from 5de2223 to d4bc308 Compare June 6, 2019 01:26
@gregmagolan gregmagolan force-pushed the sfeir-open-source/feat/entry-point branch 4 times, most recently from ba05673 to 80415b5 Compare June 6, 2019 04:53
…le entry_point change (bazel-contrib#480)

Also updates parcel example entry_point to label
@gregmagolan gregmagolan force-pushed the sfeir-open-source/feat/entry-point branch from 4d66dbd to 02e19b7 Compare June 6, 2019 21:17
@alexeagle alexeagle added cla: yes and removed cla: no labels Jun 6, 2019
@googlebot
Copy link

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.

@alexeagle alexeagle merged commit 0976086 into bazel-contrib:master Jun 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for entry points relative to current BUILD file directory
4 participants