Skip to content

feat: support array values for devtool option#20191

Merged
alexander-akait merged 2 commits intomainfrom
feat-css-devtool
Dec 21, 2025
Merged

feat: support array values for devtool option#20191
alexander-akait merged 2 commits intomainfrom
feat-css-devtool

Conversation

@hai-x
Copy link
Member

@hai-x hai-x commented Nov 29, 2025

Summary

What kind of change does this PR introduce?

Support multiple types for options.devtool to improve integration with native CSS modules.

Note that when options.devtool is defined as an array, accessing options.devtool will still return a string. This behavior is preserved intentionally for backward compatibility for some plugins (e.g. options.devtool === "eval", typeof options.devtool === "string").

Did you add tests for your changes?

Yes

Does this PR introduce a breaking change?

No

If relevant, what needs to be documented once your changes are merged or what have you already documented?

devtool and experiments.css

@changeset-bot
Copy link

changeset-bot bot commented Nov 29, 2025

🦋 Changeset detected

Latest commit: 4f2bf33

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
webpack Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Nov 29, 2025

This PR is packaged and the instant preview is available (b0e0e4c).

Install it locally:

  • npm
npm i -D webpack@https://pkg.pr.new/webpack@b0e0e4c
  • yarn
yarn add -D webpack@https://pkg.pr.new/webpack@b0e0e4c
  • pnpm
pnpm add -D webpack@https://pkg.pr.new/webpack@b0e0e4c

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 29, 2025

CodSpeed Performance Report

Merging #20191 will not alter performance

Comparing feat-css-devtool (4f2bf33) with main (3ae1004)

Summary

✅ 72 untouched

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, let's add a test cases

Another problem - we should allow to set CSS source map values by user too, like hidden-source-map and etc

So I am think about to allow devtool accepts arrays, but because we can't change devtool type for webpack@5, let's add an internal option (devtoolByTypes, maybe better name in normalization) and store source map values for types there, i.e.

devtool can be string | { test: Rule, type: "source-map" | "hidden-source-map" | "etc" }, but then in normalization we found a JS value and set it to devtool (to keep devtool a string), technically we can just take the first value of an array (but feel free to think here)

: /\.((c|m)?js|css)($|\?)/i;

new Plugin({
test: evalWrapped ? undefined : assetExt,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In EvalSourceMapDevToolPlugin, test is for module resources rather than asset file. To avoid breaking logic for .ts modules, we leave it as undefined.

@hai-x hai-x marked this pull request as ready for review December 11, 2025 18:30
@hai-x hai-x force-pushed the feat-css-devtool branch 7 times, most recently from e188e1c to 222c667 Compare December 15, 2025 17:57
css: true,
outputModule: true
},
devtool: "source-map",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hai-x Let's add a test case where we set it to devtool: [...]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for review. Let we re-use this test case here and just change the value to devtool: [...].

@alexander-akait
Copy link
Member

@hai-x Also let's rebase and we can merge 👍

@hai-x hai-x changed the title feat: support sourcemap for experiments css when using eval devtool feat: support array values for devtool option Dec 18, 2025
@hai-x hai-x force-pushed the feat-css-devtool branch 2 times, most recently from 3d7f4ad to 96dfa25 Compare December 18, 2025 17:08
@alexander-akait
Copy link
Member

@hai-x let's fix failed test, just need to update snapshots 😄

@alexander-akait alexander-akait merged commit b0e0e4c into main Dec 21, 2025
52 checks passed
@alexander-akait alexander-akait deleted the feat-css-devtool branch December 21, 2025 21:12
@alexander-akait
Copy link
Member

Thanks

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.

2 participants

Comments