From 7a411cd1d5ec40146c5664bddc64f6fd24324efa Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Mon, 8 Apr 2024 22:13:27 -0700 Subject: [PATCH] refactor: rename include_npm_linked_packages to include_npm_sources && JsInfo npm_linked_packages to npm_sources (#1623) --- docs/js_binary.md | 12 ++++---- docs/js_info_files.md | 4 +-- docs/js_run_binary.md | 6 ++-- js/defs.bzl | 26 +++++++++++++++++ js/libs.bzl | 4 +-- js/private/js_binary.bzl | 6 ++-- js/private/js_helpers.bzl | 28 +++++++++---------- js/private/js_info.bzl | 12 ++++---- js/private/js_info_files.bzl | 6 ++-- js/private/js_library.bzl | 8 +++--- js/private/js_run_binary.bzl | 17 ++++++++--- js/private/js_run_devserver.bzl | 2 +- .../test/create_launcher/custom_test.bzl | 2 +- npm/private/npm_link_package_store.bzl | 2 +- npm/private/utils.bzl | 2 +- 15 files changed, 86 insertions(+), 51 deletions(-) diff --git a/docs/js_binary.md b/docs/js_binary.md index 25f469659..e8f06c05a 100644 --- a/docs/js_binary.md +++ b/docs/js_binary.md @@ -23,9 +23,9 @@ js_binary(
 js_binary(name, chdir, copy_data_to_bin, data, enable_runfiles, entry_point, env,
-          expected_exit_code, fixed_args, include_declarations, include_npm,
-          include_npm_linked_packages, include_transitive_sources, log_level, no_copy_to_bin,
-          node_options, node_toolchain, patch_node_fs, preserve_symlinks_main)
+          expected_exit_code, fixed_args, include_declarations, include_npm, include_npm_sources,
+          include_transitive_sources, log_level, no_copy_to_bin, node_options, node_toolchain,
+          patch_node_fs, preserve_symlinks_main)
 
Execute a program in the Node.js runtime. @@ -78,7 +78,7 @@ The following environment variables are made available to the Node.js runtime ba | fixed_args | Fixed command line arguments to pass to the Node.js when this binary target is executed.

Subject to [$(location)](https://bazel.build/reference/be/make-variables#predefined_label_variables) and ["Make variable"](https://bazel.build/reference/be/make-variables) substitution.

Unlike the built-in args, which are only passed to the target when it is executed either by the bazel run command or as a test, fixed_args are baked into the generated launcher script so are always passed even when the binary target is run outside of Bazel directly from the launcher script.

fixed_args are passed before the ones specified in args and before ones that are specified on the bazel run or bazel test command line.

See https://bazel.build/reference/be/common-definitions#common-attributes-binaries for more info on the built-in args attribute. | List of strings | optional | [] | | include_declarations | When True, declarations and transitive_declarations from JsInfo providers in data targets are included in the runfiles of the target.

Defaults to false since declarations are generally not needed at runtime and introducing them could slow down developer round trip time due to having to generate typings on source file changes. | Boolean | optional | False | | include_npm | When True, npm is included in the runfiles of the target.

An npm binary is also added on the PATH so tools can spawn npm processes. This is a bash script on Linux and MacOS and a batch script on Windows.

A minimum of rules_nodejs version 5.7.0 is required which contains the Node.js toolchain changes to use npm. | Boolean | optional | False | -| include_npm_linked_packages | When True, files in npm_linked_packages from JsInfo providers in data targets are included in the runfiles of the target.

transitive_files from NpmPackageStoreInfo providers in data targets are also included in the runfiles of the target. | Boolean | optional | True | +| include_npm_sources | When True, files in npm_sources from JsInfo providers in data targets are included in the runfiles of the target.

transitive_files from NpmPackageStoreInfo providers in data targets are also included in the runfiles of the target. | Boolean | optional | True | | include_transitive_sources | When True, transitive_sources from JsInfo providers in data targets are included in the runfiles of the target. | Boolean | optional | True | | log_level | Set the logging level.

Log from are written to stderr. They will be supressed on success when running as the tool of a js_run_binary when silent_on_success is True. In that case, they will be shown only on a build failure along with the stdout & stderr of the node tool being run.

Log levels: fatal, error, warn, info, debug | String | optional | "error" | | no_copy_to_bin | List of files to not copy to the Bazel output tree when copy_data_to_bin is True.

This is useful for exceptional cases where a copy_to_bin is not possible or not suitable for an input file such as a file in an external repository. In most cases, this option is not needed. See copy_data_to_bin docstring for more info. | List of labels | optional | [] | @@ -94,7 +94,7 @@ The following environment variables are made available to the Node.js runtime ba
 js_test(name, chdir, copy_data_to_bin, data, enable_runfiles, entry_point, env, expected_exit_code,
-        fixed_args, include_declarations, include_npm, include_npm_linked_packages,
+        fixed_args, include_declarations, include_npm, include_npm_sources,
         include_transitive_sources, log_level, no_copy_to_bin, node_options, node_toolchain,
         patch_node_fs, preserve_symlinks_main)
 
@@ -137,7 +137,7 @@ the contract between Bazel and a test runner. | fixed_args | Fixed command line arguments to pass to the Node.js when this binary target is executed.

Subject to [$(location)](https://bazel.build/reference/be/make-variables#predefined_label_variables) and ["Make variable"](https://bazel.build/reference/be/make-variables) substitution.

Unlike the built-in args, which are only passed to the target when it is executed either by the bazel run command or as a test, fixed_args are baked into the generated launcher script so are always passed even when the binary target is run outside of Bazel directly from the launcher script.

fixed_args are passed before the ones specified in args and before ones that are specified on the bazel run or bazel test command line.

See https://bazel.build/reference/be/common-definitions#common-attributes-binaries for more info on the built-in args attribute. | List of strings | optional | [] | | include_declarations | When True, declarations and transitive_declarations from JsInfo providers in data targets are included in the runfiles of the target.

Defaults to false since declarations are generally not needed at runtime and introducing them could slow down developer round trip time due to having to generate typings on source file changes. | Boolean | optional | False | | include_npm | When True, npm is included in the runfiles of the target.

An npm binary is also added on the PATH so tools can spawn npm processes. This is a bash script on Linux and MacOS and a batch script on Windows.

A minimum of rules_nodejs version 5.7.0 is required which contains the Node.js toolchain changes to use npm. | Boolean | optional | False | -| include_npm_linked_packages | When True, files in npm_linked_packages from JsInfo providers in data targets are included in the runfiles of the target.

transitive_files from NpmPackageStoreInfo providers in data targets are also included in the runfiles of the target. | Boolean | optional | True | +| include_npm_sources | When True, files in npm_sources from JsInfo providers in data targets are included in the runfiles of the target.

transitive_files from NpmPackageStoreInfo providers in data targets are also included in the runfiles of the target. | Boolean | optional | True | | include_transitive_sources | When True, transitive_sources from JsInfo providers in data targets are included in the runfiles of the target. | Boolean | optional | True | | log_level | Set the logging level.

Log from are written to stderr. They will be supressed on success when running as the tool of a js_run_binary when silent_on_success is True. In that case, they will be shown only on a build failure along with the stdout & stderr of the node tool being run.

Log levels: fatal, error, warn, info, debug | String | optional | "error" | | no_copy_to_bin | List of files to not copy to the Bazel output tree when copy_data_to_bin is True.

This is useful for exceptional cases where a copy_to_bin is not possible or not suitable for an input file such as a file in an external repository. In most cases, this option is not needed. See copy_data_to_bin docstring for more info. | List of labels | optional | [] | diff --git a/docs/js_info_files.md b/docs/js_info_files.md index c5a8e7f4a..35628baca 100644 --- a/docs/js_info_files.md +++ b/docs/js_info_files.md @@ -7,7 +7,7 @@ Helper rule to gather files from JsInfo providers of targets and provide them as ## js_info_files
-js_info_files(name, include_declarations, include_npm_linked_packages, include_sources,
+js_info_files(name, include_declarations, include_npm_sources, include_sources,
               include_transitive_declarations, include_transitive_sources, srcs)
 
@@ -23,7 +23,7 @@ This helper rule is used by the `js_run_binary` macro. | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | | include_declarations | When True, declarations from JsInfo providers in srcs targets are included in the default outputs of the target.

Defaults to False since declarations are generally not needed at runtime and introducing them could slow down developer round trip time due to having to generate typings on source file changes. | Boolean | optional | False | -| include_npm_linked_packages | When True, files in npm_linked_packages from JsInfo providers in srcs targets are included in the default outputs of the target.

transitive_files from NpmPackageStoreInfo providers in data targets are also included in the default outputs of the target. | Boolean | optional | True | +| include_npm_sources | When True, files in npm_sources from JsInfo providers in srcs targets are included in the default outputs of the target.

transitive_files from NpmPackageStoreInfo providers in data targets are also included in the default outputs of the target. | Boolean | optional | True | | include_sources | When True, sources from JsInfo providers in srcs targets are included in the default outputs of the target. | Boolean | optional | True | | include_transitive_declarations | When True, transitive_declarations from JsInfo providers in srcs targets are included in the default outputs of the target.

Defaults to False since declarations are generally not needed at runtime and introducing them could slow down developer round trip time due to having to generate typings on source file changes. | Boolean | optional | False | | include_transitive_sources | When True, transitive_sources from JsInfo providers in srcs targets are included in the default outputs of the target. | Boolean | optional | True | diff --git a/docs/js_run_binary.md b/docs/js_run_binary.md index 7b62a5a03..8be29bfd0 100644 --- a/docs/js_run_binary.md +++ b/docs/js_run_binary.md @@ -19,8 +19,8 @@ load("@aspect_rules_js//js:defs.bzl", "js_run_binary")
 js_run_binary(name, tool, env, srcs, outs, out_dirs, args, chdir, stdout, stderr, exit_code_out,
               silent_on_success, use_execroot_entry_point, copy_srcs_to_bin,
-              include_transitive_sources, include_declarations, include_npm_linked_packages,
-              log_level, mnemonic, progress_message, execution_requirements, stamp, patch_node_fs,
+              include_transitive_sources, include_declarations, include_npm_sources, log_level,
+              mnemonic, progress_message, execution_requirements, stamp, patch_node_fs,
               allow_execroot_entry_point_with_no_copy_data_to_bin, use_default_shell_env, kwargs)
 
@@ -64,7 +64,7 @@ The following environment variables are made available to the Node.js runtime ba | copy_srcs_to_bin | When True, all srcs files are copied to the output tree that are not already there. | True | | include_transitive_sources | see js_info_files documentation | True | | include_declarations | see js_info_files documentation | False | -| include_npm_linked_packages | see js_info_files documentation | True | +| include_npm_sources | see js_info_files documentation | True | | log_level | Set the logging level of the js_binary tool.

This overrides the log level set on the js_binary tool target. | None | | mnemonic | A one-word description of the action, for example, CppCompile or GoLink. | "JsRunBinary" | | progress_message | Progress message to show to the user during the build, for example, "Compiling foo.cc to create foo.o". The message may contain %{label}, %{input}, or %{output} patterns, which are substituted with label string, first input, or output's path, respectively. Prefer to use patterns instead of static strings, because the former are more efficient. | None | diff --git a/js/defs.bzl b/js/defs.bzl index 623a4b999..629f8271d 100644 --- a/js/defs.bzl +++ b/js/defs.bzl @@ -26,8 +26,21 @@ load( _js_image_layer = "js_image_layer", ) +# buildifier: disable=function-docstring def js_binary(**kwargs): + include_npm_sources = kwargs.pop("include_npm_sources", True) + + # For backward compat + # TODO(3.0): remove backward compat handling + include_npm_linked_packages = kwargs.pop("include_npm_linked_packages", None) + if include_npm_linked_packages != None: + # buildifier: disable=print + print(""" +WARNING: js_binary 'include_npm_linked_packages' is deprecated. Use 'include_npm_sources' instead.""") + include_npm_sources = include_npm_linked_packages + _js_binary( + include_npm_sources = include_npm_sources, enable_runfiles = select({ Label("@aspect_bazel_lib//lib:enable_runfiles"): True, "//conditions:default": False, @@ -35,8 +48,21 @@ def js_binary(**kwargs): **kwargs ) +# buildifier: disable=function-docstring def js_test(**kwargs): + include_npm_sources = kwargs.pop("include_npm_sources", True) + + # For backward compat + # TODO(3.0): remove backward compat handling + include_npm_linked_packages = kwargs.pop("include_npm_linked_packages", None) + if include_npm_linked_packages != None: + # buildifier: disable=print + print(""" +WARNING: js_test 'include_npm_linked_packages' is deprecated. Use 'include_npm_sources' instead.""") + include_npm_sources = include_npm_linked_packages + _js_test( + include_npm_sources = include_npm_sources, enable_runfiles = select({ Label("@aspect_bazel_lib//lib:enable_runfiles"): True, "//conditions:default": False, diff --git a/js/libs.bzl b/js/libs.bzl index 693d3e5bd..a746bbadb 100644 --- a/js/libs.bzl +++ b/js/libs.bzl @@ -15,8 +15,8 @@ load( _LOG_LEVELS = "LOG_LEVELS", _envs_for_log_level = "envs_for_log_level", _gather_files_from_js_info = "gather_files_from_js_info", - _gather_npm_linked_packages = "gather_npm_linked_packages", _gather_npm_package_store_infos = "gather_npm_package_store_infos", + _gather_npm_sources = "gather_npm_sources", _gather_runfiles = "gather_runfiles", _gather_transitive_declarations = "gather_transitive_declarations", _gather_transitive_sources = "gather_transitive_sources", @@ -28,7 +28,7 @@ js_library_lib = _js_library_lib js_lib_helpers = struct( envs_for_log_level = _envs_for_log_level, gather_files_from_js_info = _gather_files_from_js_info, - gather_npm_linked_packages = _gather_npm_linked_packages, + gather_npm_sources = _gather_npm_sources, gather_npm_package_store_infos = _gather_npm_package_store_infos, gather_runfiles = _gather_runfiles, gather_transitive_declarations = _gather_transitive_declarations, diff --git a/js/private/js_binary.bzl b/js/private/js_binary.bzl index 365db6fcc..33ea3b4eb 100644 --- a/js/private/js_binary.bzl +++ b/js/private/js_binary.bzl @@ -198,8 +198,8 @@ _ATTRS = { time due to having to generate typings on source file changes.""", default = False, ), - "include_npm_linked_packages": attr.bool( - doc = """When True, files in `npm_linked_packages` from `JsInfo` providers in data targets are included in the runfiles of the target. + "include_npm_sources": attr.bool( + doc = """When True, files in `npm_sources` from `JsInfo` providers in data targets are included in the runfiles of the target. `transitive_files` from `NpmPackageStoreInfo` providers in data targets are also included in the runfiles of the target. """, @@ -517,7 +517,7 @@ def _create_launcher(ctx, log_prefix_rule_set, log_prefix_rule, fixed_args = [], no_copy_to_bin = ctx.files.no_copy_to_bin, include_transitive_sources = ctx.attr.include_transitive_sources, include_declarations = ctx.attr.include_declarations, - include_npm_linked_packages = ctx.attr.include_npm_linked_packages, + include_npm_sources = ctx.attr.include_npm_sources, ).merge(ctx.runfiles( files = launcher_files, transitive_files = transitive_launcher_files, diff --git a/js/private/js_helpers.bzl b/js/private/js_helpers.bzl index a46f97256..11093968a 100644 --- a/js/private/js_helpers.bzl +++ b/js/private/js_helpers.bzl @@ -73,21 +73,21 @@ def gather_transitive_declarations(declarations, targets): ] return depset([], transitive = [declarations] + transitive) -def gather_npm_linked_packages(srcs, deps): - """Gathers npm linked packages from a list of srcs and deps targets +def gather_npm_sources(srcs, deps): + """Gathers npm sources from a list of srcs and deps targets Args: srcs: source targets; these typically come from the `srcs` and/or `data` attributes of a rule deps: dep targets; these typically come from the `deps` attribute of a rule Returns: - Depset of npm linked package files + Depset of npm sources """ return depset([], transitive = [ - target[JsInfo].npm_linked_packages + target[JsInfo].npm_sources for target in srcs + deps - if JsInfo in target and hasattr(target[JsInfo], "npm_linked_packages") + if JsInfo in target and hasattr(target[JsInfo], "npm_sources") ]) def gather_npm_package_store_infos(targets): @@ -157,11 +157,11 @@ def gather_runfiles( include_transitive_sources = True, include_declarations = False, include_transitive_declarations = False, - include_npm_linked_packages = True): + include_npm_sources = True): """Creates a runfiles object containing files in `sources`, default outputs from `data` and transitive runfiles from `data` & `deps`. As a defense in depth against `data` & `deps` targets not supplying all required runfiles, also - gathers the transitive sources & transitive npm linked packages from the `JsInfo` & + gathers the transitive sources & transitive npm sources from the `JsInfo` & `NpmPackageStoreInfo` providers of `data` & `deps` targets. See https://bazel.build/extending/rules#runfiles for more info on providing runfiles in build rules. @@ -201,7 +201,7 @@ def gather_runfiles( include_transitive_declarations: see js_info_files documentation - include_npm_linked_packages: see js_info_files documentation + include_npm_sources: see js_info_files documentation Returns: A [runfiles](https://bazel.build/rules/lib/runfiles) object created with [ctx.runfiles](https://bazel.build/rules/lib/ctx#runfiles). @@ -225,7 +225,7 @@ def gather_runfiles( include_transitive_sources = include_transitive_sources, include_declarations = include_declarations, include_transitive_declarations = include_transitive_declarations, - include_npm_linked_packages = include_npm_linked_packages, + include_npm_sources = include_npm_sources, )) files_runfiles = [] @@ -288,7 +288,7 @@ def gather_files_from_js_info( include_transitive_sources, include_declarations, include_transitive_declarations, - include_npm_linked_packages): + include_npm_sources): """Gathers files from JsInfo and NpmPackageStoreInfo providers. Args: @@ -297,7 +297,7 @@ def gather_files_from_js_info( include_transitive_sources: see js_info_files documentation include_declarations: see js_info_files documentation include_transitive_declarations: see js_info_files documentation - include_npm_linked_packages: see js_info_files documentation + include_npm_sources: see js_info_files documentation Returns: A depset of files @@ -327,11 +327,11 @@ def gather_files_from_js_info( for target in targets if JsInfo in target and hasattr(target[JsInfo], "transitive_declarations") ]) - if include_npm_linked_packages: + if include_npm_sources: files_depsets.extend([ - target[JsInfo].npm_linked_packages + target[JsInfo].npm_sources for target in targets - if JsInfo in target and hasattr(target[JsInfo], "npm_linked_packages") + if JsInfo in target and hasattr(target[JsInfo], "npm_sources") ]) files_depsets.extend([ target[NpmPackageStoreInfo].transitive_files diff --git a/js/private/js_info.bzl b/js/private/js_info.bzl index 3a07bd0d9..cde5e6dd6 100644 --- a/js/private/js_info.bzl +++ b/js/private/js_info.bzl @@ -4,7 +4,7 @@ JsInfo = provider( doc = "Encapsulates information provided by rules in rules_js and derivative rule sets", fields = { "declarations": "A depset of declaration files produced by the target", - "npm_linked_packages": "A depset of files in npm linked package dependencies of the target and the target's transitive deps", + "npm_sources": "A depset of files in npm package dependencies of the target and the target's transitive deps", "npm_package_store_infos": "A depset of NpmPackageStoreInfo providers from non-dev npm dependencies of the target and the target's transitive dependencies to use as direct dependencies when linking downstream npm_package targets with npm_link_package", "sources": "A depset of source files produced by the target", "transitive_declarations": "A depset of declaration files produced by the target and the target's transitive deps", @@ -14,7 +14,7 @@ JsInfo = provider( def js_info( declarations = depset(), - npm_linked_packages = depset(), + npm_sources = depset(), npm_package_store_infos = depset(), sources = depset(), transitive_declarations = depset(), @@ -23,7 +23,7 @@ def js_info( Args: declarations: See JsInfo documentation - npm_linked_packages: See JsInfo documentation + npm_sources: See JsInfo documentation npm_package_store_infos: See JsInfo documentation sources: See JsInfo documentation transitive_declarations: See JsInfo documentation @@ -34,8 +34,8 @@ def js_info( """ if type(declarations) != "depset": fail("Expected declarations to be a depset") - if type(npm_linked_packages) != "depset": - fail("Expected npm_linked_packages to be a depset") + if type(npm_sources) != "depset": + fail("Expected npm_sources to be a depset") if type(npm_package_store_infos) != "depset": fail("Expected npm_package_store_infos to be a depset") if type(sources) != "depset": @@ -47,7 +47,7 @@ def js_info( return JsInfo( declarations = declarations, - npm_linked_packages = npm_linked_packages, + npm_sources = npm_sources, npm_package_store_infos = npm_package_store_infos, sources = sources, transitive_declarations = transitive_declarations, diff --git a/js/private/js_info_files.bzl b/js/private/js_info_files.bzl index 7ddf4be89..e1e396de3 100644 --- a/js/private/js_info_files.bzl +++ b/js/private/js_info_files.bzl @@ -14,7 +14,7 @@ def _js_info_files_impl(ctx): include_transitive_sources = ctx.attr.include_transitive_sources, include_declarations = ctx.attr.include_declarations, include_transitive_declarations = ctx.attr.include_transitive_declarations, - include_npm_linked_packages = ctx.attr.include_npm_linked_packages, + include_npm_sources = ctx.attr.include_npm_sources, )) js_info_files = rule( @@ -47,8 +47,8 @@ js_info_files = rule( time due to having to generate typings on source file changes.""", default = False, ), - "include_npm_linked_packages": attr.bool( - doc = """When True, files in `npm_linked_packages` from `JsInfo` providers in srcs targets are included in the default outputs of the target. + "include_npm_sources": attr.bool( + doc = """When True, files in `npm_sources` from `JsInfo` providers in srcs targets are included in the default outputs of the target. `transitive_files` from `NpmPackageStoreInfo` providers in data targets are also included in the default outputs of the target. """, diff --git a/js/private/js_library.bzl b/js/private/js_library.bzl index 49451ac53..cff8c0e73 100644 --- a/js/private/js_library.bzl +++ b/js/private/js_library.bzl @@ -24,7 +24,7 @@ js_library( """ load(":js_info.bzl", "JsInfo", "js_info") -load(":js_helpers.bzl", "DOWNSTREAM_LINKED_NPM_DEPS_DOCSTRING", "JS_LIBRARY_DATA_ATTR", "copy_js_file_to_bin_action", "gather_npm_linked_packages", "gather_npm_package_store_infos", "gather_runfiles", "gather_transitive_declarations", "gather_transitive_sources") +load(":js_helpers.bzl", "DOWNSTREAM_LINKED_NPM_DEPS_DOCSTRING", "JS_LIBRARY_DATA_ATTR", "copy_js_file_to_bin_action", "gather_npm_package_store_infos", "gather_npm_sources", "gather_runfiles", "gather_transitive_declarations", "gather_transitive_sources") load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "COPY_FILE_TO_BIN_TOOLCHAINS") _DOC = """A library of JavaScript sources. Provides JsInfo, the primary provider used in rules_js @@ -190,7 +190,7 @@ def _js_library_impl(ctx): targets = ctx.attr.srcs + ctx.attr.declarations + ctx.attr.deps, ) - npm_linked_packages = gather_npm_linked_packages( + npm_sources = gather_npm_sources( srcs = ctx.attr.srcs + ctx.attr.declarations, deps = ctx.attr.deps, ) @@ -209,13 +209,13 @@ def _js_library_impl(ctx): no_copy_to_bin = ctx.files.no_copy_to_bin, include_transitive_sources = True, include_declarations = False, - include_npm_linked_packages = True, + include_npm_sources = True, ) return [ js_info( declarations = declarations, - npm_linked_packages = npm_linked_packages, + npm_sources = npm_sources, npm_package_store_infos = npm_package_store_infos, sources = sources, transitive_declarations = transitive_declarations, diff --git a/js/private/js_run_binary.bzl b/js/private/js_run_binary.bzl index 35811cb09..e1959e708 100644 --- a/js/private/js_run_binary.bzl +++ b/js/private/js_run_binary.bzl @@ -35,7 +35,7 @@ def js_run_binary( copy_srcs_to_bin = True, include_transitive_sources = True, include_declarations = False, - include_npm_linked_packages = True, + include_npm_sources = True, log_level = None, mnemonic = "JsRunBinary", progress_message = None, @@ -154,7 +154,7 @@ def js_run_binary( include_declarations: see `js_info_files` documentation - include_npm_linked_packages: see `js_info_files` documentation + include_npm_sources: see `js_info_files` documentation log_level: Set the logging level of the `js_binary` tool. @@ -242,12 +242,21 @@ def js_run_binary( if "deps" in kwargs.keys(): fail("Use srcs instead of deps in js_run_binary: https://docs.aspect.build/rules/aspect_rules_js/docs/js_run_binary#srcs") + # For backward compat + # TODO(3.0): remove backward compat handling + include_npm_linked_packages = kwargs.pop("include_npm_linked_packages", None) + if include_npm_linked_packages != None: + # buildifier: disable=print + print(""" +WARNING: js_run_binary 'include_npm_linked_packages' is deprecated. Use 'include_npm_sources' instead.""") + include_npm_sources = include_npm_linked_packages + extra_srcs = [] # Hoist js provider files to DefaultInfo make_js_info_files_target = (include_transitive_sources or include_declarations or - include_npm_linked_packages) + include_npm_sources) if make_js_info_files_target: js_info_files_name = "{}_js_info_files".format(name) _js_info_files( @@ -255,7 +264,7 @@ def js_run_binary( srcs = srcs, include_transitive_sources = include_transitive_sources, include_declarations = include_declarations, - include_npm_linked_packages = include_npm_linked_packages, + include_npm_sources = include_npm_sources, # Always tag the target manual since we should only build it when the final target is built. tags = kwargs.get("tags", []) + ["manual"], # Always propagate the testonly attribute diff --git a/js/private/js_run_devserver.bzl b/js/private/js_run_devserver.bzl index 904a52f66..4fac64482 100644 --- a/js/private/js_run_devserver.bzl +++ b/js/private/js_run_devserver.bzl @@ -46,7 +46,7 @@ def _js_run_devserver_impl(ctx): include_transitive_sources = ctx.attr.include_transitive_sources, include_declarations = ctx.attr.include_declarations, include_transitive_declarations = ctx.attr.include_declarations, - include_npm_linked_packages = ctx.attr.include_npm_linked_packages, + include_npm_sources = ctx.attr.include_npm_sources, )] # The .to_list() calls here are intentional and cannot be avoided; they should be small sets of diff --git a/js/private/test/create_launcher/custom_test.bzl b/js/private/test/create_launcher/custom_test.bzl index 62d26b1f6..498f345ea 100644 --- a/js/private/test/create_launcher/custom_test.bzl +++ b/js/private/test/create_launcher/custom_test.bzl @@ -25,7 +25,7 @@ def _custom_test_impl(ctx): include_transitive_sources = ctx.attr.include_transitive_sources, include_declarations = ctx.attr.include_declarations, include_transitive_declarations = ctx.attr.include_declarations, - include_npm_linked_packages = ctx.attr.include_npm_linked_packages, + include_npm_sources = ctx.attr.include_npm_sources, ), ).merge(launcher.runfiles).merge_all([ target[DefaultInfo].default_runfiles diff --git a/npm/private/npm_link_package_store.bzl b/npm/private/npm_link_package_store.bzl index 11b945f7d..1ad9ed06a 100644 --- a/npm/private/npm_link_package_store.bzl +++ b/npm/private/npm_link_package_store.bzl @@ -105,7 +105,7 @@ def _npm_link_package_store_impl(ctx): runfiles = ctx.runfiles(transitive_files = transitive_files_depset), ), js_info( - npm_linked_packages = transitive_files_depset, + npm_sources = transitive_files_depset, # only propagate non-dev npm dependencies to use as direct dependencies when linking downstream npm_package targets with npm_link_package npm_package_store_infos = depset([store_info]) if not store_info.dev else depset(), ), diff --git a/npm/private/utils.bzl b/npm/private/utils.bzl index c3edd0e4b..628932c5c 100644 --- a/npm/private/utils.bzl +++ b/npm/private/utils.bzl @@ -441,7 +441,7 @@ utils = struct( package_store_root = ".aspect_rules_js", # Suffix for npm_import links repository links_repo_suffix = "__links", - # Output group name for the package directory of a linked package + # Output group name for the package directory of a linked npm package package_directory_output_group = "package_directory", npm_registry_url = _npm_registry_url, npm_registry_download_url = _npm_registry_download_url,