feat: support array values for devtool option#20191
Conversation
🦋 Changeset detectedLatest commit: 4f2bf33 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
This PR is packaged and the instant preview is available (b0e0e4c). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@b0e0e4c
yarn add -D webpack@https://pkg.pr.new/webpack@b0e0e4c
pnpm add -D webpack@https://pkg.pr.new/webpack@b0e0e4c |
CodSpeed Performance ReportMerging #20191 will not alter performanceComparing Summary
|
alexander-akait
left a comment
There was a problem hiding this comment.
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)
cb94128 to
4ab8b46
Compare
| : /\.((c|m)?js|css)($|\?)/i; | ||
|
|
||
| new Plugin({ | ||
| test: evalWrapped ? undefined : assetExt, |
There was a problem hiding this comment.
In EvalSourceMapDevToolPlugin, test is for module resources rather than asset file. To avoid breaking logic for .ts modules, we leave it as undefined.
57b0fae to
8f82a04
Compare
e188e1c to
222c667
Compare
| css: true, | ||
| outputModule: true | ||
| }, | ||
| devtool: "source-map", |
There was a problem hiding this comment.
@hai-x Let's add a test case where we set it to devtool: [...]
There was a problem hiding this comment.
Thanks for review. Let we re-use this test case here and just change the value to devtool: [...].
|
@hai-x Also let's rebase and we can merge 👍 |
3d7f4ad to
96dfa25
Compare
|
@hai-x let's fix failed test, just need to update snapshots 😄 |
96dfa25 to
08a8d6b
Compare
08a8d6b to
9b1c728
Compare
|
Thanks |
Summary
What kind of change does this PR introduce?
Support multiple types for
options.devtoolto improve integration with native CSS modules.Note that when
options.devtoolis defined as an array, accessingoptions.devtoolwill still return astring. 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?
devtoolandexperiments.css