Skip to content

refactor: pass mode and devtool as environment variables#196

Draft
acozzette wants to merge 1 commit into
aspect-build:mainfrom
acozzette:config
Draft

refactor: pass mode and devtool as environment variables#196
acozzette wants to merge 1 commit 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)

12 test targets passed

Targets
//.github/workflows:bazel7.update_test [k8-fastbuild]                        94ms
//docs:update_test [k8-fastbuild]                                            22ms
//tools:preset.update_test [k8-fastbuild]                                    95ms
//webpack/tests/create_configs:tests_0_test [k8-fastbuild]                   99ms
//webpack/tests/create_configs:tests_1_test [k8-fastbuild]                   86ms
//webpack/tests/create_configs:tests_2_test [k8-fastbuild]                   100ms
//webpack/tests/create_configs:tests_3_test [k8-fastbuild]                   96ms
//webpack/tests/devtool-override:write_bundle_test [k8-fastbuild]            41ms
//webpack/tests/simple:bundle_no_execroot_entry_point_matches [k8-fastbuild] 41ms
//webpack/tests/simple:entries_match [k8-fastbuild]                          41ms
//webpack/tests/simple:write_bundle_test [k8-fastbuild]                      44ms
//webpack/tests/worker:write_bundle_test [k8-fastbuild]                      47ms

Bazel 8 (Test)

8 test targets passed

Targets
//webpack/tests/create_configs:tests_0_test [k8-fastbuild]                   87ms
//webpack/tests/create_configs:tests_1_test [k8-fastbuild]                   66ms
//webpack/tests/create_configs:tests_2_test [k8-fastbuild]                   109ms
//webpack/tests/create_configs:tests_3_test [k8-fastbuild]                   78ms
//webpack/tests/simple:bundle_no_execroot_entry_point_matches [k8-fastbuild] 35ms
//webpack/tests/simple:entries_match [k8-fastbuild]                          59ms
//webpack/tests/simple:write_bundle_test [k8-fastbuild]                      66ms
//webpack/tests/worker:write_bundle_test [k8-fastbuild]                      38ms

Total test execution time was 538ms. 1 test (11.1%) was fully cached saving 105ms.


Bazel 9 (Test)

4 test targets passed

Targets
//webpack/tests/create_configs:tests_0_test [k8-fastbuild] 143ms
//webpack/tests/create_configs:tests_1_test [k8-fastbuild] 159ms
//webpack/tests/create_configs:tests_2_test [k8-fastbuild] 136ms
//webpack/tests/create_configs:tests_3_test [k8-fastbuild] 143ms

Total test execution time was 581ms. 5 tests (55.6%) were fully cached saving 461ms.


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]                                                       27ms

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]                                          20ms
//src:bundles_1_test [k8-fastbuild]                                          53ms

Bazel 8 (Test)

e2e/smoke

All tests were cache hits

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


Bazel 9 (Test)

e2e/smoke

1 test target passed

Targets
//src:bundles_0_test [k8-fastbuild]                        33ms

Total test execution time was 33ms. 1 test (50.0%) was fully cached saving 91ms.


Bazel 7 (Test)

e2e/worker

2 test targets passed

Targets
//:bundles_match [k8-fastbuild]                                              27ms
//:write_bundle_test [k8-fastbuild]                                          27ms

Bazel 8 (Test)

e2e/worker

2 test targets passed

Targets
//:bundles_match [k8-fastbuild]                                              71ms
//:write_bundle_test [k8-fastbuild]                                          70ms

Bazel 9 (Test)

e2e/worker

All tests were cache hits

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


Buildifier

Buildifier lint check has failed

(23:26:41) �[35mWARNING: �[0moption '--config=ci' (source command line options) was expanded and now overrides the explicit option --color=no with --color=yes
(23:26:41) �[35mWARNING: �[0moption '--config=ci' (source command line options) was expanded and now overrides the explicit option --curses=no with --curses=yes
(23:26:41) �[35mWARNING: �[0moption '--show_progress_rate_limit' was expanded to from both option '--config=workflows' (source command line options) and option '--config=ci' (source command line options)
(23:26:41) �[35mWARNING: �[0moption '--config=ci' (source command line options) was expanded and now overrides the explicit option --show_timestamps=false with --show_timestamps
(23:26:41) �[31m�[1mERROR: �[0mFailed to query remote execution capabilities: The client supported API versions, 2.0 to 2.0, is not supported by the server, 2.3 to 2.11. Please switch to a different server or upgrade Bazel.
(23:26:42) �[35mWARNING: �[0moption '--config=ci' (source command line options) was expanded and now overrides the explicit option --color=no with --color=yes
(23:26:42) �[35mWARNING: �[0moption '--config=ci' (source command line options) was expanded and now overrides the explicit option --curses=no with --curses=yes
(23:26:42) �[35mWARNING: �[0moption '--show_progress_rate_limit' was expanded to from both option '--config=workflows' (source command line options) and option '--config=ci' (source command line options)
(23:26:42) �[35mWARNING: �[0moption '--config=ci' (source command line options) was expanded and now overrides the explicit option --show_timestamps=false with --show_timestamps
(23:26:42) �[35mWARNING: �[0mUploading BEP referenced local file: The client supported API versions, 2.0 to 2.0, is not supported by the server, 2.3 to 2.11. Please switch to a different server or upgrade Bazel.
(23:26:42) �[35mWARNING: �[0mUploading BEP referenced local file /mnt/ephemeral/output/rules_webpack/__main__/command.profile.gz hash: "4aca45ac43dafadf3d0ca1bf

... 613 chars truncated

💡 To reproduce the buildifier failures, run

bazel run //:buildifier.check

Some lint failures can be fixed automatically by running the following while other require manual fixes

bazel run //:buildifier

📝 For more information on how to resolve or suppress specific lint failures, see the Buildifier documentation


Gazelle

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