diff --git a/docs/rules.md b/docs/rules.md index 68a4b46..6ba5afe 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -5,38 +5,13 @@ Public API surface is re-exported here. Users should not load files under "/internal" - - -## webpack_binary - -
-webpack_binary(name, node_modules) -- -Create a webpack binary target from linked node_modules in the user's workspace. - -The following three packages must be linked into the node_modules supplied: - - webpack, webpack-cli, webpack-dev-server - - -**PARAMETERS** - - -| Name | Description | Default Value | -| :------------- | :------------- | :------------- | -| name | Unique name for the binary target | none | -| node_modules | Label pointing to the linked node_modules target where webpack is linked, e.g.
//:node_modules
. | none |
-
-
## webpack_bundle
webpack_bundle(name, node_modules, srcs, args, deps, chdir, data, env, output_dir, entry_point, - entry_points, webpack_config, use_execroot_entry_point, supports_workers, - allow_execroot_entry_point_with_no_copy_data_to_bin, kwargs) + entry_points, webpack_config, use_execroot_entry_point, supports_workers, kwargs)Runs the webpack-cli under bazel @@ -47,7 +22,7 @@ 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
.//:node_modules
.[]
|
| args | Command line arguments to pass to Webpack.bazel
with --subcommands
to see what Webpack CLI command line was invoked.[]
|
| deps | Runtime dependencies which may be loaded during compilation. | []
|
@@ -58,9 +33,8 @@ Runs the webpack-cli under bazel
| entry_point | The point where to start the application bundling process.entry_point
to entry_points
must be specified if output_dir
is False
. | None
|
| entry_points | The map of entry points to bundle names.entry_point
to entry_points
must be specified if output_dir
is False
. | {}
|
| webpack_config | Webpack configuration file.None
|
-| 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.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.webpack
js_binary
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
|
+| 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.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.False
|
-| allow_execroot_entry_point_with_no_copy_data_to_bin | Turn off validation that the webpack
js_binary
has copy_data_to_bin
set to True when use_execroot_entry_point
is set to True.use_execroot_entry_point
doc for more info. | False
|
| kwargs | Additional arguments | none |
@@ -86,7 +60,7 @@ 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
.//:node_modules
.None
|
| env | Environment variables of the action.$(location)
and make variable expansion. | {}
|
| entry_point | The point where to start the application bundling process.entry_point
to entry_points
must be specified. | None
|
diff --git a/e2e/worker/BUILD.bazel b/e2e/worker/BUILD.bazel
index 4809df9..43cd181 100644
--- a/e2e/worker/BUILD.bazel
+++ b/e2e/worker/BUILD.bazel
@@ -1,4 +1,5 @@
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
+load("@aspect_bazel_lib//lib:diff_test.bzl", "diff_test")
load("@aspect_rules_webpack//webpack:defs.bzl", "webpack_bundle")
load("@npm//:defs.bzl", "npm_link_all_packages")
@@ -17,3 +18,17 @@ write_source_files(
"expected.js_": ":bundle.js",
},
)
+
+webpack_bundle(
+ name = "bundle_no_execroot_entry_point",
+ entry_point = "module.js",
+ node_modules = "//:node_modules",
+ supports_workers = True,
+ use_execroot_entry_point = False,
+)
+
+diff_test(
+ name = "bundles_match",
+ file1 = "bundle.js",
+ file2 = "bundle_no_execroot_entry_point.js",
+)
diff --git a/webpack/defs.bzl b/webpack/defs.bzl
index 140f9de..629aeac 100644
--- a/webpack/defs.bzl
+++ b/webpack/defs.bzl
@@ -17,9 +17,8 @@
Users should not load files under "/internal"
"""
-load("//webpack/private:webpack_bundle.bzl", _webpack_binary = "webpack_binary", _webpack_bundle = "webpack_bundle")
+load("//webpack/private:webpack_bundle.bzl", _webpack_bundle = "webpack_bundle")
load("//webpack/private:webpack_devserver.bzl", _webpack_devserver = "webpack_devserver")
-webpack_binary = _webpack_binary
webpack_bundle = _webpack_bundle
webpack_devserver = _webpack_devserver
diff --git a/webpack/private/BUILD.bazel b/webpack/private/BUILD.bazel
index 8f3e911..5ad35a9 100644
--- a/webpack/private/BUILD.bazel
+++ b/webpack/private/BUILD.bazel
@@ -1,10 +1,18 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
+bzl_library(
+ name = "webpack_binary",
+ srcs = ["webpack_binary.bzl"],
+ visibility = ["//webpack:__subpackages__"],
+)
+
bzl_library(
name = "webpack_bundle",
srcs = ["webpack_bundle.bzl"],
visibility = ["//webpack:__subpackages__"],
deps = [
+ ":webpack_binary",
+ ":webpack_create_configs",
"@aspect_bazel_lib//lib:copy_file",
"@aspect_bazel_lib//lib:copy_to_bin",
"@aspect_rules_js//js:libs",
@@ -12,11 +20,21 @@ bzl_library(
],
)
+bzl_library(
+ name = "webpack_create_configs",
+ srcs = ["webpack_create_configs.bzl"],
+ visibility = ["//webpack:__subpackages__"],
+)
+
bzl_library(
name = "webpack_devserver",
srcs = ["webpack_devserver.bzl"],
visibility = ["//webpack:__subpackages__"],
- deps = ["@aspect_rules_js//js:defs"],
+ deps = [
+ ":webpack_binary",
+ ":webpack_create_configs",
+ "@aspect_rules_js//js:defs",
+ ],
)
exports_files([
diff --git a/webpack/private/webpack_binary.bzl b/webpack/private/webpack_binary.bzl
new file mode 100644
index 0000000..4dc5d31
--- /dev/null
+++ b/webpack/private/webpack_binary.bzl
@@ -0,0 +1,35 @@
+"""webpack_binary helper macro"""
+
+load("@aspect_bazel_lib//lib:directory_path.bzl", "directory_path")
+load("@aspect_rules_js//js:defs.bzl", "js_binary")
+
+def webpack_binary(
+ name,
+ node_modules,
+ additional_packages):
+ """Create a webpack binary target from linked node_modules in the user's workspace.
+
+ Requires that `webpack` and any additional packages specified are linked into the supplied node_modules tree.
+
+ Args:
+ name: Unique name for the binary target
+ node_modules: Label pointing to the linked node_modules tree where webpack is linked, e.g. `//:node_modules`.
+ additional_packages: list of additional packages required. For example ["webpack-cli", "webpack-dev-server"]
+ """
+
+ directory_path(
+ name = "{}_entrypoint".format(name),
+ directory = "{}/webpack/dir".format(node_modules),
+ path = "bin/webpack.js",
+ )
+
+ data = ["{}/webpack".format(node_modules)]
+ for p in additional_packages:
+ data.append("{}/{}".format(node_modules, p))
+
+ js_binary(
+ name = name,
+ data = data,
+ entry_point = ":{}_entrypoint".format(name),
+ visibility = ["//visibility:public"],
+ )
diff --git a/webpack/private/webpack_bundle.bzl b/webpack/private/webpack_bundle.bzl
index c39df92..6b9da30 100644
--- a/webpack/private/webpack_bundle.bzl
+++ b/webpack/private/webpack_bundle.bzl
@@ -2,12 +2,13 @@
load("@aspect_bazel_lib//lib:copy_file.bzl", "copy_file")
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_files_to_bin_actions")
-load("@aspect_bazel_lib//lib:directory_path.bzl", "directory_path")
load("@aspect_bazel_lib//lib:expand_make_vars.bzl", "expand_locations", "expand_variables")
-load("@bazel_skylib//lib:paths.bzl", "paths")
load("@aspect_rules_js//js:defs.bzl", "js_binary")
load("@aspect_rules_js//js:libs.bzl", "js_lib_helpers")
load("@aspect_rules_js//js:providers.bzl", "JsInfo", "js_info")
+load("@bazel_skylib//lib:paths.bzl", "paths")
+load(":webpack_binary.bzl", "webpack_binary")
+load(":webpack_create_configs.bzl", "webpack_create_configs")
_attrs = {
"args": attr.string_list(
@@ -56,47 +57,12 @@ _attrs = {
"use_execroot_entry_point": attr.bool(
default = True,
),
- "allow_execroot_entry_point_with_no_copy_data_to_bin": attr.bool(),
"_worker_js": attr.label(
allow_single_file = True,
default = "@aspect_rules_js//js/private/worker:worker.js",
),
}
-_config_attrs = {
- "chdir": attr.string(),
- "entry_points": attr.label_keyed_string_dict(
- allow_files = True,
- ),
- "config_out": attr.output(),
- "output_dir": attr.bool(),
- "_webpack_config_file": attr.label(
- doc = "Internal use only",
- allow_single_file = [".js"],
- default = Label("//webpack/private:webpack.config.js"),
- ),
-}
-
-def _desugar_entry_points(entry_points):
- """Converts from dict[target: string] to dict[file: string] to a validated dict[file: string] for which every key corresponds to exactly one file.
-
- Args:
- entry_points: ctx.attr.entry_points
- Returns:
- Dictionary mapping from file to target name.
-
- See: https://github.com/bazelbuild/bazel/issues/5355
- """
- result = {}
- for ep in entry_points.items():
- entry_point = ep[0]
- name = ep[1]
- f = entry_point.files.to_list()
- if len(f) != 1:
- fail("webpack_bundle entry points must provide one file, but %s has %s" % (entry_point.label, len(f)))
- result[f[0]] = name
- return result
-
def _outs(entry_points, output_dir):
"""Supply some labelled outputs in the common case of a single entry point"""
result = {}
@@ -118,41 +84,6 @@ def _relpath(ctx, file):
fail("Expected {} to be of type File, not {}".format(file, type(file)))
return paths.relativize(file.short_path, ctx.attr.chdir)
-def _create_base_config_impl(ctx):
- inputs = []
-
- # Desugar entrypoints
- entry_points = _desugar_entry_points(ctx.attr.entry_points).items()
- entry_mapping = {}
- for entry_point in entry_points:
- entry_mapping[entry_point[1]] = "./%s" % _relpath(ctx, entry_point[0])
-
- # Change source-map and mode based on compilation mode
- # See: https://docs.bazel.build/versions/main/user-manual.html#flag--compilation_mode
- # See: https://webpack.js.org/configuration/devtool/#devtool
- compilation_mode = ctx.var["COMPILATION_MODE"]
- devtool = None
- mode = "development"
-
- if compilation_mode == "fastbuild":
- devtool = "eval"
- elif compilation_mode == "dbg":
- devtool = "eval-source-map"
- elif compilation_mode == "opt":
- mode = "production"
-
- # Expand webpack config for the entry mapping
- inputs.append(config)
- ctx.actions.expand_template(
- template = ctx.file._webpack_config_file,
- output = ctx.outputs.config_out,
- substitutions = {
- "{ ENTRIES }": json.encode(entry_mapping),
- "devtool: 'DEVTOOL',": "devtool: '{}',".format(devtool) if devtool else "",
- "mode: 'MODE',": "mode: '{}',".format(mode),
- },
- )
-
def _impl(ctx):
output_sources = [getattr(ctx.outputs, o) for o in dir(ctx.outputs)]
@@ -180,8 +111,6 @@ def _impl(ctx):
}
if ctx.attr.use_execroot_entry_point:
env["JS_BINARY__USE_EXECROOT_ENTRY_POINT"] = "1"
- if ctx.attr.allow_execroot_entry_point_with_no_copy_data_to_bin:
- env["JS_BINARY__ALLOW_EXECROOT_ENTRY_POINT_WITH_NO_COPY_DATA_TO_BIN"] = "1"
if ctx.attr.chdir:
env["JS_BINARY__CHDIR"] = ctx.attr.chdir
entry_points_srcs = ctx.attr.entry_points.keys()
@@ -204,12 +133,12 @@ def _impl(ctx):
no_copy_bin_inputs.append(ctx.file._worker_js)
- # TODO: get this path right!
+ path_to_execroot = ("/".join([".."] * len(ctx.label.package.split("/"))) if ctx.label.package else ".") + "/"
if ctx.attr.use_execroot_entry_point:
env["JS_BINARY__ALLOW_EXECROOT_ENTRY_POINT_WITH_NO_COPY_DATA_TO_BIN"] = "1"
- env["RULES_JS_WORKER"] = "/".join([".."] * len(ctx.label.package.split("/"))) + "/../../../external/burn/" + ctx.file._worker_js.short_path
+ env["RULES_JS_WORKER"] = path_to_execroot + "../../../" + ctx.file._worker_js.path
else:
- env["RULES_JS_WORKER"] = "/".join([".."] * len(ctx.label.package.split("/"))) + "/../../../" + ctx.file._worker_js.short_path
+ env["RULES_JS_WORKER"] = path_to_execroot + ctx.file._worker_js.short_path
# Set to use a multiline param-file for worker mode
args.use_param_file("@%s", use_always = True)
@@ -313,48 +242,6 @@ _webpack_bundle = rule(
doc = "",
)
-_create_base_config = rule(
- implementation = _create_base_config_impl,
- attrs = _config_attrs,
- doc = "",
-)
-
-def webpack_create_configs(name, entry_point, entry_points, webpack_config, chdir, entry_points_mandatory):
- """
- Internal use only. Not public API.
-
- Convert the given entry point[s] rule API into a set of webpack config files.
-
- Args:
- name: the main target name this config is for
- entry_point: a single entry
- entry_points: multiple entries
- webpack_config: a custom webpack config file
- chdir: the dir webpack is run in
- entry_points_mandatory: whether or not entry points must be specified
-
- Returns:
- A list of config files to pass to webpack
- """
-
- if entry_point and entry_points:
- fail("Cannot specify both entry_point and entry_points")
- if entry_points_mandatory and not entry_point and not entry_points:
- fail("One of entry_point or entry_points must be specified")
-
- default_config = "%s.webpack.config.js" % name
- _create_base_config(
- name = "_%s_config" % name,
- config_out = default_config,
- entry_points = {entry_point: name} if entry_point else entry_points,
- chdir = chdir,
- tags = ["manual"],
- )
-
- # NOTE: generated base config should always come first as it provides sensible defaults under bazel which
- # users might want to override. Also, webpack_worker uses the first webpack config path as the worker key.
- return [default_config] + ([webpack_config] if webpack_config else [])
-
def webpack_bundle(
name,
node_modules,
@@ -370,7 +257,6 @@ def webpack_bundle(
webpack_config = None,
use_execroot_entry_point = True,
supports_workers = False,
- allow_execroot_entry_point_with_no_copy_data_to_bin = False,
**kwargs):
"""Runs the webpack-cli under bazel
@@ -380,9 +266,9 @@ def webpack_bundle(
node_modules: Label pointing to the linked node_modules target where
webpack is linked, e.g. `//:node_modules`.
- The following three packages must be linked into the node_modules supplied:
+ The following packages must be linked into the node_modules supplied:
- webpack, webpack-cli, webpack-dev-server
+ webpack, webpack-cli
srcs: Non-entry point JavaScript source files from the workspace.
@@ -447,18 +333,10 @@ def webpack_bundle(
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 `webpack` `js_binary` 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.
-
supports_workers: Experimental! Use only with caution.
Allows you to enable the Bazel Worker strategy for this library.
- allow_execroot_entry_point_with_no_copy_data_to_bin: Turn off validation that the `webpack` `js_binary` has `copy_data_to_bin` set to True when `use_execroot_entry_point` is set to True.
-
- See `use_execroot_entry_point` doc for more info.
-
**kwargs: Additional arguments
"""
@@ -467,6 +345,7 @@ def webpack_bundle(
webpack_binary(
name = webpack_binary_target,
node_modules = node_modules,
+ additional_packages = ["webpack-cli"],
)
webpack_configs = webpack_create_configs(
@@ -516,36 +395,5 @@ def webpack_bundle(
webpack_worker_target_cfg = webpack_worker_binary_target,
use_execroot_entry_point = use_execroot_entry_point,
supports_workers = supports_workers,
- allow_execroot_entry_point_with_no_copy_data_to_bin = allow_execroot_entry_point_with_no_copy_data_to_bin,
**kwargs
)
-
-def webpack_binary(name, node_modules):
- """Create a webpack binary target from linked node_modules in the user's workspace.
-
- The following three packages must be linked into the node_modules supplied:
-
- webpack, webpack-cli, webpack-dev-server
-
- Args:
- name: Unique name for the binary target
- node_modules: Label pointing to the linked node_modules target where
- webpack is linked, e.g. `//:node_modules`.
- """
-
- directory_path(
- name = "{}_entrypoint".format(name),
- directory = "{}/webpack/dir".format(node_modules),
- path = "bin/webpack.js",
- )
-
- js_binary(
- name = name,
- data = [
- "{}/webpack".format(node_modules),
- "{}/webpack-cli".format(node_modules),
- "{}/webpack-dev-server".format(node_modules),
- ],
- entry_point = ":{}_entrypoint".format(name),
- visibility = ["//visibility:public"],
- )
diff --git a/webpack/private/webpack_create_configs.bzl b/webpack/private/webpack_create_configs.bzl
new file mode 100644
index 0000000..8f6316c
--- /dev/null
+++ b/webpack/private/webpack_create_configs.bzl
@@ -0,0 +1,120 @@
+"""webpack_create_configs rule"""
+
+load("@bazel_skylib//lib:paths.bzl", "paths")
+
+_config_attrs = {
+ "chdir": attr.string(),
+ "entry_points": attr.label_keyed_string_dict(
+ allow_files = True,
+ ),
+ "config_out": attr.output(),
+ "output_dir": attr.bool(),
+ "_webpack_config_file": attr.label(
+ doc = "Internal use only",
+ allow_single_file = [".js"],
+ default = Label("//webpack/private:webpack.config.js"),
+ ),
+}
+
+def _desugar_entry_points(entry_points):
+ """Converts from dict[target: string] to dict[file: string] to a validated dict[file: string] for which every key corresponds to exactly one file.
+
+ Args:
+ entry_points: ctx.attr.entry_points
+ Returns:
+ Dictionary mapping from file to target name.
+
+ See: https://github.com/bazelbuild/bazel/issues/5355
+ """
+ result = {}
+ for ep in entry_points.items():
+ entry_point = ep[0]
+ name = ep[1]
+ f = entry_point.files.to_list()
+ if len(f) != 1:
+ fail("webpack_bundle entry points must provide one file, but %s has %s" % (entry_point.label, len(f)))
+ result[f[0]] = name
+ return result
+
+def _relpath(ctx, file):
+ """Path from the working directory to a given file object"""
+ if type(file) != "File":
+ fail("Expected {} to be of type File, not {}".format(file, type(file)))
+ return paths.relativize(file.short_path, ctx.attr.chdir)
+
+def _create_base_config_impl(ctx):
+ inputs = []
+
+ # Desugar entrypoints
+ entry_points = _desugar_entry_points(ctx.attr.entry_points).items()
+ entry_mapping = {}
+ for entry_point in entry_points:
+ entry_mapping[entry_point[1]] = "./%s" % _relpath(ctx, entry_point[0])
+
+ # Change source-map and mode based on compilation mode
+ # See: https://docs.bazel.build/versions/main/user-manual.html#flag--compilation_mode
+ # See: https://webpack.js.org/configuration/devtool/#devtool
+ compilation_mode = ctx.var["COMPILATION_MODE"]
+ devtool = None
+ mode = "development"
+
+ if compilation_mode == "fastbuild":
+ devtool = "eval"
+ elif compilation_mode == "dbg":
+ devtool = "eval-source-map"
+ elif compilation_mode == "opt":
+ mode = "production"
+
+ # Expand webpack config for the entry mapping
+ inputs.append(config)
+ ctx.actions.expand_template(
+ template = ctx.file._webpack_config_file,
+ output = ctx.outputs.config_out,
+ substitutions = {
+ "{ ENTRIES }": json.encode(entry_mapping),
+ "devtool: 'DEVTOOL',": "devtool: '{}',".format(devtool) if devtool else "",
+ "mode: 'MODE',": "mode: '{}',".format(mode),
+ },
+ )
+
+_create_base_config = rule(
+ implementation = _create_base_config_impl,
+ attrs = _config_attrs,
+ doc = "",
+)
+
+def webpack_create_configs(name, entry_point, entry_points, webpack_config, chdir, entry_points_mandatory):
+ """
+ Internal use only. Not public API.
+
+ Convert the given entry point[s] rule API into a set of webpack config files.
+
+ Args:
+ name: the main target name this config is for
+ entry_point: a single entry
+ entry_points: multiple entries
+ webpack_config: a custom webpack config file
+ chdir: the dir webpack is run in
+ entry_points_mandatory: whether or not entry points must be specified
+
+ Returns:
+ A list of config files to pass to webpack
+ """
+
+ if entry_point and entry_points:
+ fail("Cannot specify both entry_point and entry_points")
+ if entry_points_mandatory and not entry_point and not entry_points:
+ fail("One of entry_point or entry_points must be specified")
+
+ default_config = "%s.webpack.config.js" % name
+ _create_base_config(
+ name = "_%s_config" % name,
+ config_out = default_config,
+ entry_points = {entry_point: name} if entry_point else entry_points,
+ chdir = chdir,
+ tags = ["manual"],
+ )
+
+ # NOTE: generated base config should always come first as it provides sensible defaults under bazel which
+ # users might want to override. Also, webpack_worker uses the first webpack config path as the worker key.
+ return [default_config] + ([webpack_config] if webpack_config else [])
diff --git a/webpack/private/webpack_devserver.bzl b/webpack/private/webpack_devserver.bzl
index 7983ee1..3906ccf 100644
--- a/webpack/private/webpack_devserver.bzl
+++ b/webpack/private/webpack_devserver.bzl
@@ -1,7 +1,8 @@
"""Webpack devserver rule definition."""
load("@aspect_rules_js//js:defs.bzl", "js_run_devserver")
-load(":webpack_bundle.bzl", _webpack_binary = "webpack_binary", _webpack_create_configs = "webpack_create_configs")
+load(":webpack_binary.bzl", "webpack_binary")
+load(":webpack_create_configs.bzl", "webpack_create_configs")
def webpack_devserver(
name,
@@ -27,7 +28,7 @@ def webpack_devserver(
node_modules: Label pointing to the linked node_modules target where
webpack is linked, e.g. `//:node_modules`.
- The following three packages must be linked into the node_modules supplied:
+ The following packages must be linked into the node_modules supplied:
webpack, webpack-cli, webpack-dev-server
@@ -85,7 +86,7 @@ def webpack_devserver(
if chdir:
unwind_chdir_prefix = "/".join([".."] * len(chdir.split("/"))) + "/"
- webpack_configs = _webpack_create_configs(
+ webpack_configs = webpack_create_configs(
name = name,
entry_point = entry_point,
entry_points = entry_points,
@@ -104,9 +105,10 @@ def webpack_devserver(
webpack_binary_target = "_{}_webpack_binary".format(name)
- _webpack_binary(
+ webpack_binary(
name = webpack_binary_target,
node_modules = node_modules,
+ additional_packages = ["webpack-cli", "webpack-dev-server"],
)
js_run_devserver(
diff --git a/webpack/tests/simple/BUILD.bazel b/webpack/tests/simple/BUILD.bazel
index a67c6df..7d20255 100644
--- a/webpack/tests/simple/BUILD.bazel
+++ b/webpack/tests/simple/BUILD.bazel
@@ -43,3 +43,23 @@ diff_test(
file1 = "bundle.js",
file2 = "multi.js",
)
+
+webpack_bundle(
+ name = "bundle_no_execroot_entry_point",
+ srcs = [
+ "module.js",
+ ],
+ entry_point = "index.js",
+ env = {
+ "MY_ENV": "$(execpath :index.js)",
+ },
+ node_modules = "//:node_modules",
+ use_execroot_entry_point = False,
+ webpack_config = ":webpack.config.js",
+)
+
+diff_test(
+ name = "bundle_no_execroot_entry_point_matches",
+ file1 = "bundle.js",
+ file2 = "bundle_no_execroot_entry_point.js",
+)