Skip to content

Commit 83d14b1

Browse files
committed
Merge remote-tracking branch 'origin/main' into zlatkovsky/trusted-types-options
2 parents c67b17b + b471a6b commit 83d14b1

File tree

6 files changed

+73
-9
lines changed

6 files changed

+73
-9
lines changed

declarations/WebpackOptions.d.ts

+12
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@ export type EntryUnnamed = EntryItem;
162162
* Enables/Disables experiments (experimental features with relax SemVer compatibility).
163163
*/
164164
export type Experiments = ExperimentsCommon & ExperimentsExtra;
165+
/**
166+
* Extend configuration from another configuration (only works when using webpack-cli).
167+
*/
168+
export type Extends = ExtendsItem[] | ExtendsItem;
169+
/**
170+
* Path to the configuration to be extended (only works when using webpack-cli).
171+
*/
172+
export type ExtendsItem = string;
165173
/**
166174
* Specify dependencies that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle. The kind of the dependency depends on `output.libraryTarget`.
167175
*/
@@ -819,6 +827,10 @@ export interface WebpackOptions {
819827
* Enables/Disables experiments (experimental features with relax SemVer compatibility).
820828
*/
821829
experiments?: Experiments;
830+
/**
831+
* Extend configuration from another configuration (only works when using webpack-cli).
832+
*/
833+
extends?: Extends;
822834
/**
823835
* Specify dependencies that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle. The kind of the dependency depends on `output.libraryTarget`.
824836
*/

schemas/WebpackOptions.check.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

schemas/WebpackOptions.json

+21
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,24 @@
944944
}
945945
}
946946
},
947+
"Extends": {
948+
"description": "Extend configuration from another configuration (only works when using webpack-cli).",
949+
"anyOf": [
950+
{
951+
"type": "array",
952+
"items": {
953+
"$ref": "#/definitions/ExtendsItem"
954+
}
955+
},
956+
{
957+
"$ref": "#/definitions/ExtendsItem"
958+
}
959+
]
960+
},
961+
"ExtendsItem": {
962+
"description": "Path to the configuration to be extended (only works when using webpack-cli).",
963+
"type": "string"
964+
},
947965
"ExternalItem": {
948966
"description": "Specify dependency that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle. The kind of the dependency depends on `output.libraryTarget`.",
949967
"anyOf": [
@@ -5353,6 +5371,9 @@
53535371
"experiments": {
53545372
"$ref": "#/definitions/Experiments"
53555373
},
5374+
"extends": {
5375+
"$ref": "#/definitions/Extends"
5376+
},
53565377
"externals": {
53575378
"$ref": "#/definitions/Externals"
53585379
},

test/Validation.test.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe("Validation", () => {
2525
expect(msg).toMatchInlineSnapshot(`
2626
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
2727
- configuration should be an object:
28-
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
28+
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
2929
-> Options object as provided by the user."
3030
`)
3131
);
@@ -34,7 +34,7 @@ describe("Validation", () => {
3434
expect(msg).toMatchInlineSnapshot(`
3535
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
3636
- configuration should be an object:
37-
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
37+
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
3838
-> Options object as provided by the user."
3939
`)
4040
);
@@ -197,7 +197,7 @@ describe("Validation", () => {
197197
expect(msg).toMatchInlineSnapshot(`
198198
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
199199
- configuration has an unknown property 'postcss'. These properties are valid:
200-
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
200+
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
201201
-> Options object as provided by the user.
202202
For typos: please correct them.
203203
For loader options: webpack >= v2.0.0 no longer allows custom properties in configuration.
@@ -428,7 +428,7 @@ describe("Validation", () => {
428428
expect(msg).toMatchInlineSnapshot(`
429429
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
430430
- configuration has an unknown property 'debug'. These properties are valid:
431-
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
431+
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
432432
-> Options object as provided by the user.
433433
The 'debug' property was removed in webpack 2.0.0.
434434
Loaders should be updated to allow passing this option via loader options in module.rules.
@@ -484,7 +484,7 @@ describe("Validation", () => {
484484
expect(msg).toMatchInlineSnapshot(`
485485
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
486486
- configuration[1] should be an object:
487-
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
487+
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
488488
-> Options object as provided by the user."
489489
`)
490490
);
@@ -570,7 +570,7 @@ describe("Validation", () => {
570570
expect(msg).toMatchInlineSnapshot(`
571571
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
572572
- configuration has an unknown property 'rules'. These properties are valid:
573-
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
573+
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
574574
-> Options object as provided by the user.
575575
Did you mean module.rules?"
576576
`)
@@ -584,7 +584,7 @@ describe("Validation", () => {
584584
expect(msg).toMatchInlineSnapshot(`
585585
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
586586
- configuration has an unknown property 'splitChunks'. These properties are valid:
587-
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
587+
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
588588
-> Options object as provided by the user.
589589
Did you mean optimization.splitChunks?"
590590
`)
@@ -598,7 +598,7 @@ describe("Validation", () => {
598598
expect(msg).toMatchInlineSnapshot(`
599599
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
600600
- configuration has an unknown property 'noParse'. These properties are valid:
601-
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
601+
object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, extends?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? }
602602
-> Options object as provided by the user.
603603
Did you mean module.noParse?"
604604
`)

test/__snapshots__/Cli.basictest.js.snap

+26
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,32 @@ Object {
825825
"multiple": false,
826826
"simpleType": "boolean",
827827
},
828+
"extends": Object {
829+
"configs": Array [
830+
Object {
831+
"description": "Path to the configuration to be extended (only works when using webpack-cli).",
832+
"multiple": true,
833+
"path": "extends[]",
834+
"type": "string",
835+
},
836+
],
837+
"description": "Path to the configuration to be extended (only works when using webpack-cli).",
838+
"multiple": true,
839+
"simpleType": "string",
840+
},
841+
"extends-reset": Object {
842+
"configs": Array [
843+
Object {
844+
"description": "Clear all items provided in 'extends' configuration. Extend configuration from another configuration (only works when using webpack-cli).",
845+
"multiple": false,
846+
"path": "extends",
847+
"type": "reset",
848+
},
849+
],
850+
"description": "Clear all items provided in 'extends' configuration. Extend configuration from another configuration (only works when using webpack-cli).",
851+
"multiple": false,
852+
"simpleType": "boolean",
853+
},
828854
"externals": Object {
829855
"configs": Array [
830856
Object {

types.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -2196,6 +2196,11 @@ declare interface Configuration {
21962196
*/
21972197
experiments?: Experiments;
21982198

2199+
/**
2200+
* Extend configuration from another configuration (only works when using webpack-cli).
2201+
*/
2202+
extends?: string | string[];
2203+
21992204
/**
22002205
* Specify dependencies that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle. The kind of the dependency depends on `output.libraryTarget`.
22012206
*/

0 commit comments

Comments
 (0)