Skip to content

refactor: pass mode and devtool as environment variables#196

Draft
acozzette wants to merge 14 commits into
aspect-build:mainfrom
acozzette:config
Draft

refactor: pass mode and devtool as environment variables#196
acozzette wants to merge 14 commits into
aspect-build:mainfrom
acozzette:config

Conversation

@acozzette
Copy link
Copy Markdown
Contributor

With use_execroot_entry_point = False, we want Webpack config files to be built for the exec platform. However, this poses a problem for mode and devtool, which are derived from the compilation mode and are currently baked into the base config file. If we build that config file for the exec platform, then it cannot be customized based on the target platform compilation mode.

This commit solves that problem by passing this information via WEBPACK_MODE and WEBPACK_DEVTOOL environment variables. This way we can get the information we need about the compilation mode without having to hard-code it in the generated base config.

Importantly, user-provided configs can still override mode and devtool as expected, and there is even an existing test for this in webpack/tests/devtool-override.


Changes are visible to end-users: no, unless you go out of your way to look at these environment variables

Test plan

  • Covered by existing test cases

With `use_execroot_entry_point = False`, we want Webpack config files to be
built for the exec platform. However, this poses a problem for `mode` and
`devtool`, which are derived from the compilation mode and are currently baked
into the base config file. If we build that config file for the exec platform,
then it cannot be customized based on the target platform compilation mode.

This commit solves that problem by passing this information via `WEBPACK_MODE`
and `WEBPACK_DEVTOOL` environment variables. This way we can get the
information we need about the compilation mode without having to hard-code it
in the generated base config.

Importantly, user-provided configs can still override mode and devtool as
expected, and there is even an existing test for this in
`webpack/tests/devtool-override`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@aspect-workflows
Copy link
Copy Markdown

aspect-workflows Bot commented May 21, 2026

Bazel 7 (Test)

15 test targets passed

Targets
//.github/workflows:bazel7.update_test [k8-fastbuild]                        87ms
//docs:update_test [k8-fastbuild]                                            26ms
//tools:preset.update_test [k8-fastbuild]                                    79ms
//webpack/tests/create_configs:tests_0_test [k8-fastbuild]                   69ms
//webpack/tests/create_configs:tests_1_test [k8-fastbuild]                   69ms
//webpack/tests/create_configs:tests_2_test [k8-fastbuild]                   67ms
//webpack/tests/create_configs:tests_3_test [k8-fastbuild]                   71ms
//webpack/tests/devserver-configure:test_dbg [k8-fastbuild]                  61ms
//webpack/tests/devserver-configure:test_fastbuild [k8-fastbuild]            47ms
//webpack/tests/devserver-configure:test_opt [k8-fastbuild]                  62ms
//webpack/tests/devtool-override:write_bundle_test [k8-fastbuild]            66ms
//webpack/tests/simple:bundle_no_execroot_entry_point_matches [k8-fastbuild] 38ms
//webpack/tests/simple:entries_match [k8-fastbuild]                          71ms
//webpack/tests/simple:write_bundle_test [k8-fastbuild]                      46ms
//webpack/tests/worker:write_bundle_test [k8-fastbuild]                      67ms

Bazel 8 (Test)

All tests were cache hits

12 tests (100.0%) were fully cached saving 864ms.


Bazel 9 (Test)

All tests were cache hits

12 tests (100.0%) were fully cached saving 1s.


Bazel 7 (Test)

e2e/loaders

1 test target passed

Targets
//:test [k8-fastbuild]                                                       21ms

Bazel 8 (Test)

e2e/loaders

All tests were cache hits

1 test (100.0%) was fully cached saving 36ms.


Bazel 9 (Test)

e2e/loaders

All tests were cache hits

1 test (100.0%) was fully cached saving 31ms.


Bazel 7 (Test)

e2e/loaders_jslib

1 test target passed

Targets
//:test [k8-fastbuild]                                                       23ms

Bazel 8 (Test)

e2e/loaders_jslib

All tests were cache hits

1 test (100.0%) was fully cached saving 62ms.


Bazel 9 (Test)

e2e/loaders_jslib

All tests were cache hits

1 test (100.0%) was fully cached saving 32ms.


Bazel 7 (Test)

e2e/smoke

2 test targets passed

Targets
//src:bundles_0_test [k8-fastbuild]                                          24ms
//src:bundles_1_test [k8-fastbuild]                                          22ms

Bazel 8 (Test)

e2e/smoke

All tests were cache hits

2 tests (100.0%) were fully cached saving 46ms.


Bazel 9 (Test)

e2e/smoke

All tests were cache hits

2 tests (100.0%) were fully cached saving 124ms.


Bazel 7 (Test)

e2e/worker

2 test targets passed

Targets
//:bundles_match [k8-fastbuild]                                              35ms
//:write_bundle_test [k8-fastbuild]                                          34ms

Bazel 8 (Test)

e2e/worker

All tests were cache hits

2 tests (100.0%) were fully cached saving 141ms.


Bazel 9 (Test)

e2e/worker

All tests were cache hits

2 tests (100.0%) were fully cached saving 67ms.


Buildifier      Gazelle

acozzette and others added 12 commits May 22, 2026 14:08
Previously WEBPACK_DEVTOOL was hardcoded to "eval" (fastbuild). Now it
uses select() on compilation mode config_settings: "eval" for fastbuild,
"eval-source-map" for dbg, and unset for opt.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ver test

Replace the single devserver-configure test with three tests that use
Starlark transitions to build the devserver under fastbuild, dbg, and opt
compilation modes, then verify the expected WEBPACK_DEVTOOL value in each
generated launcher script.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@acozzette acozzette marked this pull request as ready for review May 22, 2026 22:51
@acozzette acozzette marked this pull request as draft May 23, 2026 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant