diff --git a/MODULE.bazel b/MODULE.bazel index f90cd28..e563e55 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -6,13 +6,14 @@ module( compatibility_level = 1, ) -bazel_dep(name = "aspect_bazel_lib", version = "1.38.1") -bazel_dep(name = "aspect_rules_js", version = "1.34.0") -bazel_dep(name = "bazel_skylib", version = "1.4.1") +# Lower-bounds (minimum) versions for direct runtime dependencies +bazel_dep(name = "aspect_bazel_lib", version = "2.7.1") +bazel_dep(name = "aspect_rules_js", version = "2.0.0-alpha.2") +bazel_dep(name = "bazel_skylib", version = "1.5.0") ####### Dev dependencies ######## bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.5.0", dev_dependency = True) bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True) bazel_dep(name = "gazelle", version = "0.36.0", dev_dependency = True, repo_name = "bazel_gazelle") -bazel_dep(name = "rules_go", version = "0.46.0", dev_dependency = True) +bazel_dep(name = "stardoc", version = "0.6.2", dev_dependency = True, repo_name = "io_bazel_stardoc") diff --git a/WORKSPACE b/WORKSPACE index 2871205..fa6a08c 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -8,24 +8,11 @@ load("//webpack:dependencies.bzl", "rules_webpack_dependencies") rules_webpack_dependencies() -load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") +load("@aspect_rules_js//js:toolchains.bzl", "DEFAULT_NODE_VERSION", "rules_js_register_toolchains") -rules_js_dependencies() +rules_js_register_toolchains(node_version = DEFAULT_NODE_VERSION) -load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies", "register_coreutils_toolchains") - -aspect_bazel_lib_dependencies() - -register_coreutils_toolchains() - -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") - -nodejs_register_toolchains( - name = "nodejs", - node_version = DEFAULT_NODE_VERSION, -) - -load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock") +load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") npm_translate_lock( name = "npm", @@ -54,6 +41,28 @@ go_register_toolchains(version = "1.19.3") gazelle_dependencies() +############################################ +# Stardoc +load("@io_bazel_stardoc//:setup.bzl", "stardoc_repositories") + +stardoc_repositories() + +load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps") + +rules_jvm_external_deps() + +load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup") + +rules_jvm_external_setup() + +load("@io_bazel_stardoc//:deps.bzl", "stardoc_external_deps") + +stardoc_external_deps() + +load("@stardoc_maven//:defs.bzl", stardoc_pinned_maven_install = "pinned_maven_install") + +stardoc_pinned_maven_install() + # Buildifier load("@buildifier_prebuilt//:deps.bzl", "buildifier_prebuilt_deps") diff --git a/docs/rules.md b/docs/rules.md index 50dc0ec..1583ca1 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -4,7 +4,6 @@ Public API surface is re-exported here. Users should not load files under "/internal" - ## webpack_bundle @@ -23,21 +22,21 @@ Runs the webpack-cli under bazel | Name | Description | Default Value | | :------------- | :------------- | :------------- | | name | A unique name for this target. | none | -| node_modules | Label pointing to the linked node_modules target where webpack is linked, e.g. //:node_modules.

The following packages must be linked into the node_modules supplied:

webpack, webpack-cli | none | -| srcs | Non-entry point JavaScript source files from the workspace.

You must not repeat file(s) passed to entry_point/entry_points. | [] | -| args | Command line arguments to pass to Webpack.

These argument passed on the command line before arguments that are added by the rule. Run bazel with --subcommands to see what Webpack CLI command line was invoked.

See the [Webpack CLI docs](https://webpack.js.org/api/cli/) for a complete list of supported arguments. | [] | -| deps | Runtime dependencies which may be loaded during compilation. | [] | -| chdir | Working directory to run Webpack under.

This is needed to workaround some buggy resolvers in webpack loaders, which assume that the node_modules tree is located in a parent of the working directory rather than a parent of the script with the require statement.

Note that any relative paths in your configuration may need to be adjusted so they are relative to the new working directory.

See also: https://github.com/aspect-build/rules_js/blob/main/docs/js_binary.md#js_binary-chdir | None | -| data | Runtime dependencies to include in binaries/tests that depend on this target.

The transitive npm dependencies, transitive sources, default outputs and runfiles of targets in the data attribute are added to the runfiles of this target. They should appear in the '*.runfiles' area of any executable which has a runtime dependency on this target. | [] | -| env | Environment variables of the action.

Subject to $(location) and make variable expansion. | {} | -| output_dir | If True, webpack produces an output directory containing all output files. | False | -| entry_point | The point where to start the application bundling process.

See https://webpack.js.org/concepts/entry-points/

Exactly one of entry_point to entry_points must be specified if output_dir is False. | None | -| entry_points | The map of entry points to bundle names.

See https://webpack.js.org/concepts/entry-points/

Exactly one of entry_point to entry_points must be specified if output_dir is False. | {} | -| webpack_config | Webpack configuration file.

See https://webpack.js.org/configuration/ | None | -| configure_mode | Configure mode in the generated base webpack config.

mode is set to production if the Bazel compilation mode is opt otherwise it is set to development.

The configured value will be overridden if it is set in a supplied webpack_config.

See https://bazel.build/docs/user-manual#compilation-mode for more info on how to configure the compilation mode. | True | -| configure_devtool | Configure devtool in the generated base webpack config.

devtool is set to eval if the Bazel compilation mode is fastbuild, eval-source-map if the Bazel compilation mode is dbg, otherwise it is left unset.

The configured value will be overridden if it is set in a supplied webpack_config.

See https://bazel.build/docs/user-manual#compilation-mode for more info on how to configure the compilation mode. | True | -| use_execroot_entry_point | Use the entry_point script of the webpack js_binary that is in the execroot output tree instead of the copy that is in runfiles.

When set, runfiles are hoisted to the target platform when this is configured and included as target platform 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. | True | -| supports_workers | Experimental! Use only with caution.

Allows you to enable the Bazel Worker strategy for this library. | False | +| node_modules | Label pointing to the linked node_modules target where webpack is linked, e.g. `//:node_modules`.

The following packages must be linked into the node_modules supplied:

webpack, webpack-cli | none | +| srcs | Non-entry point JavaScript source files from the workspace.

You must not repeat file(s) passed to entry_point/entry_points. | `[]` | +| args | Command line arguments to pass to Webpack.

These argument passed on the command line before arguments that are added by the rule. Run `bazel` with `--subcommands` to see what Webpack CLI command line was invoked.

See the [Webpack CLI docs](https://webpack.js.org/api/cli/) for a complete list of supported arguments. | `[]` | +| deps | Runtime dependencies which may be loaded during compilation. | `[]` | +| chdir | Working directory to run Webpack under.

This is needed to workaround some buggy resolvers in webpack loaders, which assume that the node_modules tree is located in a parent of the working directory rather than a parent of the script with the require statement.

Note that any relative paths in your configuration may need to be adjusted so they are relative to the new working directory.

See also: https://github.com/aspect-build/rules_js/blob/main/docs/js_binary.md#js_binary-chdir | `None` | +| data | Runtime dependencies to include in binaries/tests that depend on this target.

The transitive npm dependencies, transitive sources, default outputs and runfiles of targets in the `data` attribute are added to the runfiles of this target. They should appear in the '*.runfiles' area of any executable which has a runtime dependency on this target. | `[]` | +| env | Environment variables of the action.

Subject to `$(location)` and make variable expansion. | `{}` | +| output_dir | If True, webpack produces an output directory containing all output files. | `False` | +| entry_point | The point where to start the application bundling process.

See https://webpack.js.org/concepts/entry-points/

Exactly one of `entry_point` to `entry_points` must be specified if `output_dir` is `False`. | `None` | +| entry_points | The map of entry points to bundle names.

See https://webpack.js.org/concepts/entry-points/

Exactly one of `entry_point` to `entry_points` must be specified if `output_dir` is `False`. | `{}` | +| webpack_config | Webpack configuration file.

See https://webpack.js.org/configuration/ | `None` | +| configure_mode | Configure `mode` in the generated base webpack config.

`mode` is set to `production` if the Bazel compilation mode is `opt` otherwise it is set to `development`.

The configured value will be overridden if it is set in a supplied `webpack_config`.

See https://bazel.build/docs/user-manual#compilation-mode for more info on how to configure the compilation mode. | `True` | +| configure_devtool | Configure `devtool` in the generated base webpack config.

`devtool` is set to `eval` if the Bazel compilation mode is `fastbuild`, `eval-source-map` if the Bazel compilation mode is `dbg`, otherwise it is left unset.

The configured value will be overridden if it is set in a supplied `webpack_config`.

See https://bazel.build/docs/user-manual#compilation-mode for more info on how to configure the compilation mode. | `True` | +| use_execroot_entry_point | Use the `entry_point` script of the `webpack` `js_binary` that is in the execroot output tree instead of the copy that is in runfiles.

When set, runfiles are hoisted to the target platform when this is configured and included as target platform 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. | `True` | +| supports_workers | Experimental! Use only with caution.

Allows you to enable the Bazel Worker strategy for this library. | `False` | | kwargs | Additional arguments | none | @@ -63,17 +62,17 @@ under the hood. | Name | Description | Default Value | | :------------- | :------------- | :------------- | | name | A unique name for this target. | none | -| node_modules | Label pointing to the linked node_modules target where webpack is linked, e.g. //:node_modules.

The following packages must be linked into the node_modules supplied:

webpack, webpack-cli, webpack-dev-server | none | -| chdir | Working directory to run Webpack under.

This is needed to workaround some buggy resolvers in webpack loaders, which assume that the node_modules tree is located in a parent of the working directory rather than a parent of the script with the require statement.

Note that any relative paths in your configuration may need to be adjusted so they are relative to the new working directory.

See also: https://github.com/aspect-build/rules_js/blob/main/docs/js_binary.md#js_binary-chdir | None | -| env | Environment variables of the action.

Subject to $(location) and make variable expansion. | {} | -| entry_point | The point where to start the application bundling process.

See https://webpack.js.org/concepts/entry-points/

Only one of entry_point to entry_points must be specified. | None | -| entry_points | The map of entry points to bundle names.

See https://webpack.js.org/concepts/entry-points/

Only one of entry_point to entry_points must be specified. | {} | -| webpack_config | Webpack configuration file. See https://webpack.js.org/configuration/. | None | -| configure_mode | Configure mode in the generated base webpack config.

mode is set to production if the Bazel compilation mode is opt otherwise it is set to development.

The configured value will be overridden if it is set in a supplied webpack_config.

See https://bazel.build/docs/user-manual#compilation-mode for more info on how to configure the compilation mode. | True | -| configure_devtool | Configure devtool in the generated base webpack config.

devtool is set to eval if the Bazel compilation mode is fastbuild, eval-source-map if the Bazel compilation mode is dbg, otherwise it is left unset.

The configured value will be overridden if it is set in a supplied webpack_config.

See https://bazel.build/docs/user-manual#compilation-mode for more info on how to configure the compilation mode. | True | -| args | Additional arguments to pass to webpack.

The serve command, the webpack config file (--config) and the mode (--mode) are automatically set. | [] | -| data | Bundle and runtime dependencies of the program.

Should include the webpack_bundle rule srcs and deps.

The webpack config and entry_point[s] are automatically passed to data and should not be repeated. | [] | -| mode | The mode to pass to --mode. | "development" | +| node_modules | Label pointing to the linked node_modules target where webpack is linked, e.g. `//:node_modules`.

The following packages must be linked into the node_modules supplied:

webpack, webpack-cli, webpack-dev-server | none | +| chdir | Working directory to run Webpack under.

This is needed to workaround some buggy resolvers in webpack loaders, which assume that the node_modules tree is located in a parent of the working directory rather than a parent of the script with the require statement.

Note that any relative paths in your configuration may need to be adjusted so they are relative to the new working directory.

See also: https://github.com/aspect-build/rules_js/blob/main/docs/js_binary.md#js_binary-chdir | `None` | +| env | Environment variables of the action.

Subject to `$(location)` and make variable expansion. | `{}` | +| entry_point | The point where to start the application bundling process.

See https://webpack.js.org/concepts/entry-points/

Only one of `entry_point` to `entry_points` must be specified. | `None` | +| entry_points | The map of entry points to bundle names.

See https://webpack.js.org/concepts/entry-points/

Only one of `entry_point` to `entry_points` must be specified. | `{}` | +| webpack_config | Webpack configuration file. See https://webpack.js.org/configuration/. | `None` | +| configure_mode | Configure `mode` in the generated base webpack config.

`mode` is set to `production` if the Bazel compilation mode is `opt` otherwise it is set to `development`.

The configured value will be overridden if it is set in a supplied `webpack_config`.

See https://bazel.build/docs/user-manual#compilation-mode for more info on how to configure the compilation mode. | `True` | +| configure_devtool | Configure `devtool` in the generated base webpack config.

`devtool` is set to `eval` if the Bazel compilation mode is `fastbuild`, `eval-source-map` if the Bazel compilation mode is `dbg`, otherwise it is left unset.

The configured value will be overridden if it is set in a supplied `webpack_config`.

See https://bazel.build/docs/user-manual#compilation-mode for more info on how to configure the compilation mode. | `True` | +| args | Additional arguments to pass to webpack.

The `serve` command, the webpack config file (`--config`) and the mode (`--mode`) are automatically set. | `[]` | +| data | Bundle and runtime dependencies of the program.

Should include the `webpack_bundle` rule `srcs` and `deps`.

The webpack config and entry_point[s] are automatically passed to data and should not be repeated. | `[]` | +| mode | The mode to pass to `--mode`. | `"development"` | | kwargs | Additional arguments. See [js_run_devserver](https://github.com/aspect-build/rules_js/blob/main/docs/js_run_devserver.md). | none | diff --git a/e2e/loaders/WORKSPACE b/e2e/loaders/WORKSPACE index c34ddd5..64afe8e 100644 --- a/e2e/loaders/WORKSPACE +++ b/e2e/loaders/WORKSPACE @@ -10,21 +10,14 @@ load("@aspect_rules_webpack//webpack:dependencies.bzl", "rules_webpack_dependenc rules_webpack_dependencies() -load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") - -rules_js_dependencies() - # Fetch and register a nodejs interpreter, if you haven't already -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:toolchains.bzl", "DEFAULT_NODE_VERSION", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "node", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains(node_version = DEFAULT_NODE_VERSION) # brought as a dep by webpack ruleset -load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock") +load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") npm_translate_lock( name = "npm", diff --git a/e2e/smoke/MODULE.bazel b/e2e/smoke/MODULE.bazel index 94a609f..20c914c 100644 --- a/e2e/smoke/MODULE.bazel +++ b/e2e/smoke/MODULE.bazel @@ -1,16 +1,14 @@ -"Bazel dependencies" - -bazel_dep(name = "aspect_bazel_lib", version = "1.32.0") -bazel_dep(name = "aspect_rules_js", version = "1.33.1") -bazel_dep(name = "bazel_skylib", version = "1.4.1") - bazel_dep(name = "aspect_rules_webpack", version = "0.0.0", dev_dependency = True) local_path_override( module_name = "aspect_rules_webpack", path = "../..", ) -npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm") +bazel_dep(name = "aspect_bazel_lib", version = "2.7.1", dev_dependency = True) +bazel_dep(name = "aspect_rules_js", version = "2.0.0-alpha.2", dev_dependency = True) +bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True) + +npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True) npm.npm_translate_lock( name = "v4-npm", pnpm_lock = "//v4:pnpm-lock.yaml", diff --git a/e2e/smoke/WORKSPACE.bazel b/e2e/smoke/WORKSPACE.bazel index 2109430..0d7eb64 100644 --- a/e2e/smoke/WORKSPACE.bazel +++ b/e2e/smoke/WORKSPACE.bazel @@ -16,20 +16,13 @@ load("@aspect_rules_webpack//webpack:dependencies.bzl", "rules_webpack_dependenc rules_webpack_dependencies() -load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") - -rules_js_dependencies() - # Fetch and register a nodejs interpreter, if you haven't already -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:toolchains.bzl", "DEFAULT_NODE_VERSION", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "node", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains(node_version = DEFAULT_NODE_VERSION) -load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock") +load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") npm_translate_lock( name = "v4-npm", diff --git a/e2e/worker/WORKSPACE b/e2e/worker/WORKSPACE index 15530c7..b90f761 100644 --- a/e2e/worker/WORKSPACE +++ b/e2e/worker/WORKSPACE @@ -10,20 +10,13 @@ load("@aspect_rules_webpack//webpack:dependencies.bzl", "rules_webpack_dependenc rules_webpack_dependencies() -load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") - -rules_js_dependencies() - # Fetch and register a nodejs interpreter, if you haven't already -load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains") +load("@aspect_rules_js//js:toolchains.bzl", "DEFAULT_NODE_VERSION", "rules_js_register_toolchains") -nodejs_register_toolchains( - name = "node", - node_version = DEFAULT_NODE_VERSION, -) +rules_js_register_toolchains(node_version = DEFAULT_NODE_VERSION) -load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock") +load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock") npm_translate_lock( name = "npm", diff --git a/internal_deps.bzl b/internal_deps.bzl index 66e3675..3ef5928 100644 --- a/internal_deps.bzl +++ b/internal_deps.bzl @@ -10,14 +10,6 @@ load("//webpack/private:maybe.bzl", http_archive = "maybe_http_archive") def rules_webpack_internal_deps(): "Fetch repositories used for developing the rules" - # opt-in to 2.0 without forcing users to do so - http_archive( - name = "aspect_bazel_lib", - sha256 = "c858cc637db5370f6fd752478d1153955b4b4cbec7ffe95eb4a47a48499a79c3", - strip_prefix = "bazel-lib-2.0.3", - url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.0.3/bazel-lib-v2.0.3.tar.gz", - ) - http_archive( name = "io_bazel_rules_go", sha256 = "80a98277ad1311dacd837f9b16db62887702e9f1d1c4c9f796d0121a46c8e184", @@ -38,8 +30,8 @@ def rules_webpack_internal_deps(): http_archive( name = "io_bazel_stardoc", - sha256 = "3fd8fec4ddec3c670bd810904e2e33170bedfe12f90adf943508184be458c8bb", - urls = ["https://github.com/bazelbuild/stardoc/releases/download/0.5.3/stardoc-0.5.3.tar.gz"], + sha256 = "62bd2e60216b7a6fec3ac79341aa201e0956477e7c8f6ccc286f279ad1d96432", + urls = ["https://github.com/bazelbuild/stardoc/releases/download/0.6.2/stardoc-0.6.2.tar.gz"], ) http_archive( diff --git a/webpack/dependencies.bzl b/webpack/dependencies.bzl index 7833043..d2cf585 100644 --- a/webpack/dependencies.bzl +++ b/webpack/dependencies.bzl @@ -9,26 +9,27 @@ load("//webpack/private:maybe.bzl", http_archive = "maybe_http_archive") def rules_webpack_dependencies(): http_archive( name = "bazel_skylib", - sha256 = "b8a1527901774180afc798aeb28c4634bdccf19c4d98e7bdd1ce79d1fe9aaad7", - urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz"], + sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94", + urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz"], ) http_archive( name = "aspect_bazel_lib", - sha256 = "262e3d6693cdc16dd43880785cdae13c64e6a3f63f75b1993c716295093d117f", - strip_prefix = "bazel-lib-1.38.1", - url = "https://github.com/aspect-build/bazel-lib/releases/download/v1.38.1/bazel-lib-v1.38.1.tar.gz", + sha256 = "b554eb7942a5ab44c90077df6a0c76fc67c5874c9446a007e9ba68be82bd4796", + strip_prefix = "bazel-lib-2.7.1", + url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.7.1/bazel-lib-v2.7.1.tar.gz", ) http_archive( name = "aspect_rules_js", - sha256 = "d9ceb89e97bb5ad53b278148e01a77a3e9100db272ce4ebdcd59889d26b9076e", - strip_prefix = "rules_js-1.34.0", - url = "https://github.com/aspect-build/rules_js/releases/download/v1.34.0/rules_js-v1.34.0.tar.gz", + sha256 = "b627acf34f928507dfabae69d3fd8702ce3d45bed568ad4c44b243cb789f08c6", + strip_prefix = "rules_js-2.0.0-alpha.2", + url = "https://github.com/aspect-build/rules_js/releases/download/v2.0.0-alpha.2/rules_js-v2.0.0-alpha.2.tar.gz", ) http_archive( name = "rules_nodejs", - sha256 = "764a3b3757bb8c3c6a02ba3344731a3d71e558220adcb0cf7e43c9bba2c37ba8", - urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.2/rules_nodejs-core-5.8.2.tar.gz"], + sha256 = "dddd60acc3f2f30359bef502c9d788f67e33814b0ddd99aa27c5a15eb7a41b8c", + strip_prefix = "rules_nodejs-6.1.0", + url = "https://github.com/bazelbuild/rules_nodejs/releases/download/v6.1.0/rules_nodejs-v6.1.0.tar.gz", ) diff --git a/webpack/private/webpack_bundle.bzl b/webpack/private/webpack_bundle.bzl index 05941ab..63c97cd 100644 --- a/webpack/private/webpack_bundle.bzl +++ b/webpack/private/webpack_bundle.bzl @@ -164,12 +164,13 @@ def _impl(ctx): inputs.extend(ctx.files.entry_points) inputs = depset( copy_files_to_bin_actions(ctx, inputs) + no_copy_bin_inputs, - transitive = [webpack_runfiles] + [js_lib_helpers.gather_files_from_js_providers( + transitive = [webpack_runfiles] + [js_lib_helpers.gather_files_from_js_infos( targets = ctx.attr.srcs + ctx.attr.deps, + include_sources = True, + include_types = False, include_transitive_sources = True, - # Upstream Type-check actions should not be triggered by bundling - include_declarations = False, - include_npm_linked_packages = True, + include_transitive_types = False, + include_npm_sources = True, )], ) @@ -184,14 +185,14 @@ def _impl(ctx): env = env, ) - npm_linked_packages = js_lib_helpers.gather_npm_linked_packages( + # If a subset of linked npm dependencies are not bundled, it is up to the user to re-specify + # these in `data` if they are runtime dependencies to progagate to binary rules or `srcs` if + # they are to be propagated to downstream build targets. + npm_sources = js_lib_helpers.gather_npm_sources( srcs = ctx.attr.srcs, deps = [], ) - - npm_package_store_deps = js_lib_helpers.gather_npm_package_store_deps( - # Since we're bundling, only propagate `data` npm packages to the direct dependencies of - # downstream linked `npm_package` targets instead of the common `data` and `deps` pattern. + npm_package_store_infos = js_lib_helpers.gather_npm_package_store_infos( targets = ctx.attr.data, ) @@ -207,19 +208,15 @@ def _impl(ctx): return [ js_info( - npm_linked_package_files = npm_linked_packages.direct_files, - npm_linked_packages = npm_linked_packages.direct, - npm_package_store_deps = npm_package_store_deps, + target = ctx.label, sources = output_sources_depset, - # Since we're bundling, we don't propagate linked npm packages from dependencies since - # they are bundled and the dependencies are dropped. If a subset of linked npm - # dependencies are not bundled it is up the the user to re-specify these in `data` if - # they are runtime dependencies to propagate to binary rules or `srcs` if they are to be - # propagated to downstream build targets. - transitive_npm_linked_package_files = npm_linked_packages.transitive_files, - transitive_npm_linked_packages = npm_linked_packages.transitive, - # Since we're bundling, we don't propagate any transitive output_sources from dependencies + types = depset(), # webpack does not emit types directly + # Since we're bundling, don't propogate any transitive sources or declarations since sources + # are typically bundled into the output. transitive_sources = output_sources_depset, + transitive_types = depset(), + npm_sources = npm_sources, + npm_package_store_infos = npm_package_store_infos, ), DefaultInfo( files = output_sources_depset,