Skip to content

Commit 9fcaa24

Browse files
authored
Merge pull request #15746 from jdanil/fix/experiments-css-override
fix: allow normalised experiments css value to be false
2 parents 8f87b50 + 1857792 commit 9fcaa24

File tree

6 files changed

+94
-11
lines changed

6 files changed

+94
-11
lines changed

declarations/WebpackOptions.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3523,11 +3523,11 @@ export interface ExperimentsNormalizedExtra {
35233523
/**
35243524
* Enable css support.
35253525
*/
3526-
css?: CssExperimentOptions;
3526+
css?: false | CssExperimentOptions;
35273527
/**
35283528
* Compile entrypoints and import()s only when they are accessed.
35293529
*/
3530-
lazyCompilation?: LazyCompilationOptions;
3530+
lazyCompilation?: false | LazyCompilationOptions;
35313531
}
35323532
/**
35333533
* If an dependency matches exactly a property of the object, the property value is used as dependency.

lib/config/defaults.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ const applyJavascriptParserOptionsDefaults = (
485485
* @param {boolean} options.cache is caching enabled
486486
* @param {boolean} options.syncWebAssembly is syncWebAssembly enabled
487487
* @param {boolean} options.asyncWebAssembly is asyncWebAssembly enabled
488-
* @param {CssExperimentOptions} options.css is css enabled
488+
* @param {CssExperimentOptions|false} options.css is css enabled
489489
* @param {boolean} options.futureDefaults is future defaults enabled
490490
* @param {boolean} options.isNode is node target platform
491491
* @returns {void}
@@ -1122,7 +1122,7 @@ const applyPerformanceDefaults = (performance, { production }) => {
11221122
* @param {Object} options options
11231123
* @param {boolean} options.production is production
11241124
* @param {boolean} options.development is development
1125-
* @param {CssExperimentOptions} options.css is css enabled
1125+
* @param {CssExperimentOptions|false} options.css is css enabled
11261126
* @param {boolean} options.records using records
11271127
* @returns {void}
11281128
*/

lib/config/normalization.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,10 @@ const getNormalizedWebpackOptions = config => {
178178
),
179179
lazyCompilation: optionalNestedConfig(
180180
experiments.lazyCompilation,
181-
options =>
182-
options === true ? {} : options === false ? undefined : options
181+
options => (options === true ? {} : options)
183182
),
184183
css: optionalNestedConfig(experiments.css, options =>
185-
options === true ? {} : options === false ? undefined : options
184+
options === true ? {} : options
186185
)
187186
})),
188187
externals: config.externals,

schemas/WebpackOptions.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,10 @@
897897
},
898898
"css": {
899899
"description": "Enable css support.",
900-
"oneOf": [
900+
"anyOf": [
901+
{
902+
"enum": [false]
903+
},
901904
{
902905
"$ref": "#/definitions/CssExperimentOptions"
903906
}
@@ -913,7 +916,10 @@
913916
},
914917
"lazyCompilation": {
915918
"description": "Compile entrypoints and import()s only when they are accessed.",
916-
"oneOf": [
919+
"anyOf": [
920+
{
921+
"enum": [false]
922+
},
917923
{
918924
"$ref": "#/definitions/LazyCompilationOptions"
919925
}

test/Defaults.unittest.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2221,6 +2221,84 @@ describe("snapshots", () => {
22212221
+ /^(.+?[\\\\/]node_modules[\\\\/])/,
22222222
`)
22232223
);
2224+
2225+
test(
2226+
"experiments.futureDefaults w/ experiments.css disabled",
2227+
{
2228+
experiments: {
2229+
css: false,
2230+
futureDefaults: true
2231+
}
2232+
},
2233+
e =>
2234+
e.toMatchInlineSnapshot(`
2235+
- Expected
2236+
+ Received
2237+
2238+
@@ ... @@
2239+
- "asyncWebAssembly": false,
2240+
- "backCompat": true,
2241+
+ "asyncWebAssembly": true,
2242+
+ "backCompat": false,
2243+
@@ ... @@
2244+
- "cacheUnaffected": false,
2245+
- "css": undefined,
2246+
- "futureDefaults": false,
2247+
+ "cacheUnaffected": true,
2248+
+ "css": false,
2249+
+ "futureDefaults": true,
2250+
@@ ... @@
2251+
- "topLevelAwait": false,
2252+
+ "topLevelAwait": true,
2253+
@@ ... @@
2254+
+ },
2255+
+ Object {
2256+
+ "rules": Array [
2257+
+ Object {
2258+
+ "descriptionData": Object {
2259+
+ "type": "module",
2260+
+ },
2261+
+ "resolve": Object {
2262+
+ "fullySpecified": true,
2263+
+ },
2264+
+ },
2265+
+ ],
2266+
+ "test": /\\.wasm$/i,
2267+
+ "type": "webassembly/async",
2268+
@@ ... @@
2269+
+ "mimetype": "application/wasm",
2270+
+ "rules": Array [
2271+
+ Object {
2272+
+ "descriptionData": Object {
2273+
+ "type": "module",
2274+
+ },
2275+
+ "resolve": Object {
2276+
+ "fullySpecified": true,
2277+
+ },
2278+
+ },
2279+
+ ],
2280+
+ "type": "webassembly/async",
2281+
+ },
2282+
+ Object {
2283+
@@ ... @@
2284+
+ "exportsPresence": "error",
2285+
@@ ... @@
2286+
- "__dirname": "mock",
2287+
- "__filename": "mock",
2288+
- "global": true,
2289+
+ "__dirname": "warn-mock",
2290+
+ "__filename": "warn-mock",
2291+
+ "global": "warn",
2292+
@@ ... @@
2293+
- "hashDigestLength": 20,
2294+
- "hashFunction": "md4",
2295+
+ "hashDigestLength": 16,
2296+
+ "hashFunction": "xxhash64",
2297+
@@ ... @@
2298+
- "<cwd>/node_modules/",
2299+
+ /^(.+?[\\\\/]node_modules[\\\\/])/,
2300+
`)
2301+
);
22242302
});
22252303

22262304
it("should result in the same target options for same target", () => {

types.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3543,12 +3543,12 @@ declare interface ExperimentsNormalizedExtra {
35433543
/**
35443544
* Enable css support.
35453545
*/
3546-
css?: CssExperimentOptions;
3546+
css?: false | CssExperimentOptions;
35473547

35483548
/**
35493549
* Compile entrypoints and import()s only when they are accessed.
35503550
*/
3551-
lazyCompilation?: LazyCompilationOptions;
3551+
lazyCompilation?: false | LazyCompilationOptions;
35523552
}
35533553
declare abstract class ExportInfo {
35543554
name: string;

0 commit comments

Comments
 (0)