From 91037dd4ff3dac70be123fe0d86bc16524fe5a8d Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Fri, 19 Apr 2024 19:14:15 -0700 Subject: [PATCH] refactor: add include_sources and include_transitive_types attributes to js_binary, js_test and js_run_binary --- docs/js_binary.md | 28 +++++++++++-------- docs/js_info_files.md | 6 ++-- docs/js_run_binary.md | 13 +++++---- docs/npm_package.md | 10 +++---- js/private/js_binary.bzl | 27 ++++++++++++++---- js/private/js_helpers.bzl | 6 ++-- js/private/js_info_files.bzl | 12 ++++---- js/private/js_library.bzl | 4 ++- js/private/js_run_binary.bzl | 15 ++++++++-- .../test/create_launcher/custom_test.bzl | 4 +-- npm/private/npm_package.bzl | 12 ++++---- 11 files changed, 86 insertions(+), 51 deletions(-) diff --git a/docs/js_binary.md b/docs/js_binary.md index 47a9c67c4..137be35b8 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_npm, include_npm_sources,
-          include_transitive_sources, include_types, log_level, no_copy_to_bin, node_options,
-          node_toolchain, patch_node_fs, preserve_symlinks_main)
+          expected_exit_code, fixed_args, include_npm, include_npm_sources, include_sources,
+          include_transitive_sources, include_transitive_types, include_types, log_level,
+          no_copy_to_bin, node_options, node_toolchain, patch_node_fs, preserve_symlinks_main)
 
Execute a program in the Node.js runtime. @@ -77,9 +77,11 @@ The following environment variables are made available to the Node.js runtime ba | expected_exit_code | The expected exit code.

Can be used to write tests that are expected to fail. | Integer | optional | 0 | | 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_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_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 | -| include_types | When True, types and transitive_types from JsInfo providers in data targets are included in the runfiles of the target.

Defaults to false since types 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_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_sources | When True, sources from JsInfo providers in data targets are 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 | +| include_transitive_types | When True, transitive_types from JsInfo providers in data targets are included in the runfiles of the target.

Defaults to False since types 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_types | When True, types from JsInfo providers in data targets are included in the runfiles of the target.

Defaults to False since types 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.

NB: These are types from direct data dependencies only. You may also need to set include_transitive_types to True. | Boolean | optional | False | | 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 | [] | | node_options | Options to pass to the node invocation on the command line.

https://nodejs.org/api/cli.html

These options are passed directly to the node invocation on the command line. Options passed here will take precendence over options passed via the NODE_OPTIONS environment variable. Options passed here are not added to the NODE_OPTIONS environment variable so will not be automatically picked up by child processes that inherit that enviroment variable. | List of strings | optional | [] | @@ -94,9 +96,9 @@ 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_npm, include_npm_sources, include_transitive_sources, include_types,
-        log_level, no_copy_to_bin, node_options, node_toolchain, patch_node_fs,
-        preserve_symlinks_main)
+        fixed_args, include_npm, include_npm_sources, include_sources, include_transitive_sources,
+        include_transitive_types, include_types, log_level, no_copy_to_bin, node_options,
+        node_toolchain, patch_node_fs, preserve_symlinks_main)
 
Identical to js_binary, but usable under `bazel test`. @@ -136,9 +138,11 @@ the contract between Bazel and a test runner. | expected_exit_code | The expected exit code.

Can be used to write tests that are expected to fail. | Integer | optional | 0 | | 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_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_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 | -| include_types | When True, types and transitive_types from JsInfo providers in data targets are included in the runfiles of the target.

Defaults to false since types 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_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_sources | When True, sources from JsInfo providers in data targets are 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 | +| include_transitive_types | When True, transitive_types from JsInfo providers in data targets are included in the runfiles of the target.

Defaults to False since types 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_types | When True, types from JsInfo providers in data targets are included in the runfiles of the target.

Defaults to False since types 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.

NB: These are types from direct data dependencies only. You may also need to set include_transitive_types to True. | Boolean | optional | False | | 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 | [] | | node_options | Options to pass to the node invocation on the command line.

https://nodejs.org/api/cli.html

These options are passed directly to the node invocation on the command line. Options passed here will take precendence over options passed via the NODE_OPTIONS environment variable. Options passed here are not added to the NODE_OPTIONS environment variable so will not be automatically picked up by child processes that inherit that enviroment variable. | List of strings | optional | [] | diff --git a/docs/js_info_files.md b/docs/js_info_files.md index a30c90c22..4e33740a2 100644 --- a/docs/js_info_files.md +++ b/docs/js_info_files.md @@ -22,11 +22,11 @@ This helper rule is used by the `js_run_binary` macro. | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | -| 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_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 srcs 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_sources | When True, transitive_sources from JsInfo providers in srcs targets are included in the default outputs of the target. | Boolean | optional | True | -| include_transitive_types | When True, transitive_types from JsInfo providers in srcs targets are included in the default outputs of the target.

Defaults to False since types 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_types | When True, types from JsInfo providers in srcs targets are included in the default outputs of the target.

Defaults to False since types 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_types | When True, transitive_types from JsInfo providers in srcs targets are included in the default outputs of the target.

Defaults to False since types 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_types | When True, types from JsInfo providers in srcs targets are included in the default outputs of the target.

Defaults to False since types 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.

NB: These are types from direct srcs dependencies only. You may also need to set include_transitive_types to True. | Boolean | optional | False | | srcs | List of targets to gather files from. | List of labels | optional | [] | diff --git a/docs/js_run_binary.md b/docs/js_run_binary.md index 2cab1b0f7..8961cf7c3 100644 --- a/docs/js_run_binary.md +++ b/docs/js_run_binary.md @@ -18,10 +18,11 @@ 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_types, 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)
+              silent_on_success, use_execroot_entry_point, copy_srcs_to_bin, include_sources,
+              include_types, include_transitive_sources, include_transitive_types,
+              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)
 
Wrapper around @aspect_bazel_lib `run_binary` that adds convenience attributes for using a `js_binary` tool. @@ -62,8 +63,10 @@ The following environment variables are made available to the Node.js runtime ba | silent_on_success | produce no output on stdout nor stderr when program exits with status code 0.

This makes node binaries match the expected bazel paradigm. | True | | use_execroot_entry_point | Use the entry_point script of the js_binary tool that is in the execroot output tree instead of the copy that is in runfiles.

Runfiles of tool are all hoisted to srcs of the underlying run_binary so they are included as execroot inputs to the action.

Using the entry point script that is in the execroot output tree means that there will be no conflicting runfiles node_modules in the node_modules resolution path which can confuse npm packages such as next and react that don't like being resolved in multiple node_modules trees. This more closely emulates the environment that tools such as Next.js see when they are run outside of Bazel.

When True, the js_binary tool must have copy_data_to_bin set to True (the default) so that all data files needed by the binary are available in the execroot output tree. This requirement can be turned off with by setting allow_execroot_entry_point_with_no_copy_data_to_bin to True. | True | | 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_sources | see js_info_files documentation | True | | include_types | see js_info_files documentation | False | +| include_transitive_sources | see js_info_files documentation | True | +| include_transitive_types | see js_info_files documentation | False | | 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" | diff --git a/docs/npm_package.md b/docs/npm_package.md index 2fd92c4ff..d41cfebe1 100644 --- a/docs/npm_package.md +++ b/docs/npm_package.md @@ -18,7 +18,7 @@ load("@aspect_rules_js//npm:defs.bzl", "npm_package") npm_package(name, srcs, data, args, out, package, version, root_paths, include_external_repositories, include_srcs_packages, exclude_srcs_packages, include_srcs_patterns, exclude_srcs_patterns, replace_prefixes, allow_overwrites, - include_sources, include_transitive_sources, include_types, include_transitive_types, + include_sources, include_types, include_transitive_sources, include_transitive_types, include_runfiles, hardlink, verbose, kwargs) @@ -103,10 +103,10 @@ To stamp the current git tag as the "version" in the package.json file, see | exclude_srcs_patterns | List of paths (with glob support) to exclude from output directory.

Files in srcs are not copied to the output directory if their output directory path, after applying root_paths, matches one of the patterns specified.

Forward slashes (/) should be used as path separators.

Files that do not have matching output directory paths are subject to subsequent filters and transformations to determine if they are copied and what their path in the output directory will be.

Globs are supported (see rule docstring above). | ["**/node_modules/**"] | | replace_prefixes | Map of paths prefixes (with glob support) to replace in the output directory path when copying files.

If the output directory path for a file starts with or fully matches a a key in the dict then the matching portion of the output directory path is replaced with the dict value for that key. The final path segment matched can be a partial match of that segment and only the matching portion will be replaced. If there are multiple keys that match, the longest match wins.

Forward slashes (/) should be used as path separators.

Replace prefix transformation are the final step in the list of filters and transformations. The final output path of a file being copied into the output directory is determined at this step.

Globs are supported (see rule docstring above). | {} | | allow_overwrites | If True, allow files to be overwritten if the same output file is copied to twice.

The order of srcs matters as the last copy of a particular file will win when overwriting. Performance of npm_package will be slightly degraded when allow_overwrites is True since copies cannot be parallelized out as they are calculated. Instead all copy paths must be calculated before any copies can be started. | False | -| include_sources | When True, sources from JsInfo providers in data targets are included in the list of available files to copy. | True | -| include_transitive_sources | When True, transitive_sources from JsInfo providers in data targets are included in the list of available files to copy. | True | -| include_types | When True, types from JsInfo providers in data targets are included in the list of available files to copy. | True | -| include_transitive_types | When True, transitive_types from JsInfo providers in data targets are included in the list of available files to copy. | True | +| include_sources | When True, sources from JsInfo providers in data targets are included in the list of available files to copy. | True | +| include_types | When True, types from JsInfo providers in data targets are included in the list of available files to copy. | True | +| include_transitive_sources | When True, transitive_sources from JsInfo providers in data targets are included in the list of available files to copy. | True | +| include_transitive_types | When True, transitive_types from JsInfo providers in data targets are included in the list of available files to copy. | True | | include_runfiles | When True, default runfiles from srcs targets are included in the list of available files to copy.

This may be needed in a few cases:

- to work-around issues with rules that don't provide everything needed in sources, transitive_sources, types & transitive_types - to depend on the runfiles targets that don't use JsInfo

NB: The default value will be flipped to False in the next major release as runfiles are not needed in the general case and adding them to the list of files available to copy can add noticeable overhead to the analysis phase in a large repository with many npm_package targets. | False | | hardlink | Controls when to use hardlinks to files instead of making copies.

Creating hardlinks is much faster than making copies of files with the caveat that hardlinks share file permissions with their source.

Since Bazel removes write permissions on files in the output tree after an action completes, hardlinks to source files are not recommended since write permissions will be inadvertently removed from sources files.

- auto: hardlinks are used for generated files already in the output tree - off: all files are copied - on: hardlinks are used for all files (not recommended) | "auto" | | verbose | If true, prints out verbose logs to stdout | False | diff --git a/js/private/js_binary.bzl b/js/private/js_binary.bzl index 94c2e54d2..67ac8e30b 100644 --- a/js/private/js_binary.bzl +++ b/js/private/js_binary.bzl @@ -187,21 +187,34 @@ _ATTRS = { which can lead to non-hermetic behavior.""", default = True, ), + "include_sources": attr.bool( + doc = """When True, `sources` from `JsInfo` providers in `data` targets are included in the runfiles of the target.""", + default = True, + ), "include_transitive_sources": attr.bool( - doc = """When True, `transitive_sources` from `JsInfo` providers in data targets are included in the runfiles of the target.""", + doc = """When True, `transitive_sources` from `JsInfo` providers in `data` targets are included in the runfiles of the target.""", default = True, ), "include_types": attr.bool( - doc = """When True, `types` and `transitive_types` from `JsInfo` providers in data targets are included in the runfiles of the target. + doc = """When True, `types` from `JsInfo` providers in `data` targets are included in the runfiles of the target. + + Defaults to False since types 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. + + NB: These are types from direct `data` dependencies only. You may also need to set `include_transitive_types` to True.""", + default = False, + ), + "include_transitive_types": attr.bool( + doc = """When True, `transitive_types` from `JsInfo` providers in `data` targets are included in the runfiles of the target. - Defaults to false since types are generally not needed at runtime and introducing them could slow down developer round trip + Defaults to False since types 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.""", default = False, ), "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. + 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. + `transitive_files` from `NpmPackageStoreInfo` providers in `data` targets are also included in the runfiles of the target. """, default = True, ), @@ -515,8 +528,10 @@ def _create_launcher(ctx, log_prefix_rule_set, log_prefix_rule, fixed_args = [], deps = [], copy_data_files_to_bin = ctx.attr.copy_data_to_bin, no_copy_to_bin = ctx.files.no_copy_to_bin, - include_transitive_sources = ctx.attr.include_transitive_sources, + include_sources = ctx.attr.include_sources, include_types = ctx.attr.include_types, + include_transitive_sources = ctx.attr.include_transitive_sources, + include_transitive_types = ctx.attr.include_transitive_types, include_npm_sources = ctx.attr.include_npm_sources, ).merge(ctx.runfiles( files = launcher_files, diff --git a/js/private/js_helpers.bzl b/js/private/js_helpers.bzl index 43f3bbbe7..513526053 100644 --- a/js/private/js_helpers.bzl +++ b/js/private/js_helpers.bzl @@ -123,8 +123,8 @@ def gather_runfiles( copy_data_files_to_bin = False, no_copy_to_bin = [], include_sources = True, - include_transitive_sources = True, include_types = False, + include_transitive_sources = True, include_transitive_types = False, include_npm_sources = True): """Creates a runfiles object containing files in `sources`, default outputs from `data` and transitive runfiles from `data` & `deps`. @@ -164,10 +164,10 @@ def gather_runfiles( include_sources: see js_info_files documentation - include_transitive_sources: see js_info_files documentation - include_types: see js_info_files documentation + include_transitive_sources: see js_info_files documentation + include_transitive_types: see js_info_files documentation include_npm_sources: see js_info_files documentation diff --git a/js/private/js_info_files.bzl b/js/private/js_info_files.bzl index 15b965105..e320847e1 100644 --- a/js/private/js_info_files.bzl +++ b/js/private/js_info_files.bzl @@ -34,23 +34,25 @@ js_info_files = rule( default = True, ), "include_types": attr.bool( - doc = """When True, `types` from `JsInfo` providers in srcs targets are included in the default outputs of the target. + doc = """When True, `types` from `JsInfo` providers in `srcs` targets are included in the default outputs of the target. Defaults to False since types 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.""", + time due to having to generate typings on source file changes. + + NB: These are types from direct `srcs` dependencies only. You may also need to set `include_transitive_types` to True.""", default = False, ), "include_transitive_types": attr.bool( - doc = """When True, `transitive_types` from `JsInfo` providers in srcs targets are included in the default outputs of the target. + doc = """When True, `transitive_types` from `JsInfo` providers in `srcs` targets are included in the default outputs of the target. Defaults to False since types 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.""", default = False, ), "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. + 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. + `transitive_files` from `NpmPackageStoreInfo` providers in `srcs` targets are also included in the default outputs of the target. """, default = True, ), diff --git a/js/private/js_library.bzl b/js/private/js_library.bzl index b4d96ae0c..fa731fd59 100644 --- a/js/private/js_library.bzl +++ b/js/private/js_library.bzl @@ -234,8 +234,10 @@ def _js_library_impl(ctx): data_files = ctx.files.data, copy_data_files_to_bin = ctx.attr.copy_data_to_bin, no_copy_to_bin = ctx.files.no_copy_to_bin, - include_transitive_sources = True, + include_sources = True, include_types = False, + include_transitive_sources = True, + include_transitive_types = False, include_npm_sources = True, ) diff --git a/js/private/js_run_binary.bzl b/js/private/js_run_binary.bzl index 7c7ac77df..861fbfc0b 100644 --- a/js/private/js_run_binary.bzl +++ b/js/private/js_run_binary.bzl @@ -33,8 +33,10 @@ def js_run_binary( silent_on_success = True, use_execroot_entry_point = True, copy_srcs_to_bin = True, - include_transitive_sources = True, + include_sources = True, include_types = False, + include_transitive_sources = True, + include_transitive_types = False, include_npm_sources = True, log_level = None, mnemonic = "JsRunBinary", @@ -150,10 +152,14 @@ def js_run_binary( copy_srcs_to_bin: When True, all srcs files are copied to the output tree that are not already there. - include_transitive_sources: see `js_info_files` documentation + include_sources: see `js_info_files` documentation include_types: see `js_info_files` documentation + include_transitive_sources: see `js_info_files` documentation + + include_transitive_types: see `js_info_files` documentation + include_npm_sources: see `js_info_files` documentation log_level: Set the logging level of the `js_binary` tool. @@ -259,6 +265,7 @@ WARNING: js_run_binary 'include_npm_linked_packages' is deprecated. Use 'include print(""" WARNING: js_library 'include_declarations' is deprecated. Use 'include_types' instead.""") include_types = include_declarations + include_transitive_types = include_declarations extra_srcs = [] @@ -271,8 +278,10 @@ WARNING: js_library 'include_declarations' is deprecated. Use 'include_types' in _js_info_files( name = js_info_files_name, srcs = srcs, - include_transitive_sources = include_transitive_sources, + include_sources = include_sources, include_types = include_types, + include_transitive_sources = include_transitive_sources, + include_transitive_types = include_transitive_types, 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"], diff --git a/js/private/test/create_launcher/custom_test.bzl b/js/private/test/create_launcher/custom_test.bzl index 7ab50ac4a..97b355a9f 100644 --- a/js/private/test/create_launcher/custom_test.bzl +++ b/js/private/test/create_launcher/custom_test.bzl @@ -21,10 +21,10 @@ def _custom_test_impl(ctx): files = ctx.files.data, transitive_files = js_lib_helpers.gather_files_from_js_infos( targets = ctx.attr.data, - include_sources = True, + include_sources = ctx.attr.include_sources, include_types = ctx.attr.include_types, include_transitive_sources = ctx.attr.include_transitive_sources, - include_transitive_types = ctx.attr.include_types, + include_transitive_types = ctx.attr.include_transitive_types, include_npm_sources = ctx.attr.include_npm_sources, ), ).merge(launcher.runfiles).merge_all([ diff --git a/npm/private/npm_package.bzl b/npm/private/npm_package.bzl index 9cdebc8f2..0aca3c569 100644 --- a/npm/private/npm_package.bzl +++ b/npm/private/npm_package.bzl @@ -168,8 +168,8 @@ def npm_package( replace_prefixes = {}, allow_overwrites = False, include_sources = True, - include_transitive_sources = True, include_types = True, + include_transitive_sources = True, include_transitive_types = True, include_runfiles = False, hardlink = "auto", @@ -403,13 +403,13 @@ def npm_package( since copies cannot be parallelized out as they are calculated. Instead all copy paths must be calculated before any copies can be started. - include_sources: When True, `sources` from `JsInfo` providers in data targets are included in the list of available files to copy. + include_sources: When True, `sources` from `JsInfo` providers in `data` targets are included in the list of available files to copy. - include_transitive_sources: When True, `transitive_sources` from `JsInfo` providers in data targets are included in the list of available files to copy. + include_types: When True, `types` from `JsInfo` providers in `data` targets are included in the list of available files to copy. - include_types: When True, `types` from `JsInfo` providers in data targets are included in the list of available files to copy. + include_transitive_sources: When True, `transitive_sources` from `JsInfo` providers in `data` targets are included in the list of available files to copy. - include_transitive_types: When True, `transitive_types` from `JsInfo` providers in data targets are included in the list of available files to copy. + include_transitive_types: When True, `transitive_types` from `JsInfo` providers in `data` targets are included in the list of available files to copy. include_runfiles: When True, default runfiles from `srcs` targets are included in the list of available files to copy. @@ -446,11 +446,11 @@ def npm_package( name = files_target, srcs = srcs, include_sources = include_sources, - include_transitive_sources = include_transitive_sources, include_types = select({ "@aspect_rules_js//npm:exclude_types_from_npm_packages_flag": False, "//conditions:default": include_types, }), + include_transitive_sources = include_transitive_sources, include_transitive_types = select({ "@aspect_rules_js//npm:exclude_types_from_npm_packages_flag": False, "//conditions:default": include_transitive_types,