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(): remove _repository_args from nodejs_binary #3142

Merged
merged 1 commit into from
Dec 20, 2021

Conversation

dymart
Copy link
Collaborator

@dymart dymart commented Dec 13, 2021

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 requires _repository_args and has a dependency on @nodejs

What is the new behavior?

removes the need for @nodejs for _repository_args

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@gregmagolan
Copy link
Collaborator

gregmagolan commented Dec 14, 2021

Lets remove it out of nodejs/repositories.bzl and nodejs/private/nodejs_repo_host_os_alias.bzl in this PR along with the preserve_symlinks attribute of node_repositories

@gregmagolan
Copy link
Collaborator

gregmagolan commented Dec 14, 2021

Thinking about the current default which is to add --preserve-symlinks. I think we should just go with the nodejs default of not setting that flag and the releases notes for 5.0 should be for users to add --preserve-symlinks to their args with

nodejs_binary(
    ...
    args = ["--node_options=--preserve-symlinks"],
)

if they want it set.

@alexeagle do you think that would be too breaking? I suppose we'll see how CI is if we flip the default in RNJ.

User's would have to do this for all their nodejs_binary, nodejs_test targets. Suggestion in release notes could be to use a defaults macro.

If we don't want to flip the default, we'll need to figure out some API to have this thing be on by default outside of the standard args and templated_args.

There is some precedent with the default_env_vars, but default_args seems wrong as args are harder to override than env vars. That leaves making a special case attribute of preserve_symlinks that defaults to True for 5.0.

@dymart
Copy link
Collaborator Author

dymart commented Dec 15, 2021

I've left "--preserve-symlinks" in for right now to pass the tests. I'll keep trying to get things working with the flag removed and then flip it when that works.

@alexeagle
Copy link
Collaborator

I think this may be a use case for a custom flag.

https://docs.bazel.build/versions/main/configurable-attributes.html#custom-flags

So users would bazel build --@rules_nodejs//nodejs:default_args="--something"
the default configuration would have the --preserve-symlinks in there.

@dymart
Copy link
Collaborator Author

dymart commented Dec 16, 2021

Great thanks for the recommendation @alexeagle I'll look into using a custom flag

@dymart
Copy link
Collaborator Author

dymart commented Dec 16, 2021

Hey @alexeagle just wanted to follow up in the example you gave it has these flags living in the nodejs folder. Would these flags still be used in the internal/node/node.bzl and passed along to launcher.sh through template variables. Or is there a different way you were thinking that these flags would be integrated in.

@alexeagle
Copy link
Collaborator

I would expect the custom flag in the nodejs/ folder like that example, yes. Can then be used in internal/node/node.bzl or anywhere else that wants to reference them

@dymart dymart force-pushed the 5.args branch 3 times, most recently from 2982099 to 4d0ffec Compare December 17, 2021 17:31
# allowed args ["--preserve-symlinks", ""]
user_args(
name = "default_args",
build_setting_default = "--preserve-symlinks",
Copy link
Collaborator

Choose a reason for hiding this comment

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

if this is the default, then why did you have to add it explicitly to a bunch of examples? seems wrong, I'd expect the examples not to change, since those illustrate the changes users would have to make as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The flags were added to the examples to see how things would work when the default was changed. If we wanted to go with the nodejs default. As mentioned earlier in the comments on the pr. I'm happy to remove them from this pr though and reevaluate when we want to change the default.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think keeping the default to match what node_repositories() had makes sense for 5.0. We'd want to do some more due diligence before we flip the default.

load("//nodejs/private/providers:user_build_settings.bzl", "UserBuildSettingInfo")

# this can be used to limit user input for flags and also provide useful error messages for incorrect flags
user_args_allowed = ["--preserve-symlinks", ""]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should just open this up and let users can set whatever default they want. Guessing they can set a defaults in their .bazelrc file with this improved approach?

@dymart dymart force-pushed the 5.args branch 3 times, most recently from a897aed to 38119c9 Compare December 20, 2021 19:13
@dymart dymart force-pushed the 5.args branch 2 times, most recently from 693d79a to ce574ba Compare December 20, 2021 19:45
docs/Cypress.md Outdated
@@ -156,6 +156,10 @@ Now you can add `--config=debug` to any `bazel test` command line.
The runtime will pause before executing the program, allowing you to connect a
remote debugger.

You can also change the default args that are sent to nodejs. This can be done through a flag. The default is --preserve-symlinks while anything
can be passed. The flag is --@build_bazel_rules_nodejs//nodejs:default_args="" ex: bazel test --@build_bazel_rules_nodejs//nodejs:default_args="test" main
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lets add a real flag here to better illustrate what it does. Maybe pass two such as
"--preserve-symlinks --no-warnings" to show that you can pass multiple. A drop a link to https://nodejs.org/api/cli.html for reference.

@dymart dymart force-pushed the 5.args branch 2 times, most recently from 6fec93b to b7c4c32 Compare December 20, 2021 21:08
Copy link
Collaborator

@gregmagolan gregmagolan left a comment

Choose a reason for hiding this comment

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

🌮

@gregmagolan gregmagolan merged commit 90c7fe0 into bazelbuild:5.x Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants