fix: allow to have any properties in `experiments` to prevent validation errors when an experiment is stable

This commit is contained in:
Alexander Akait 2025-08-28 20:44:33 +03:00 committed by GitHub
parent 6b313c950d
commit b843ea827b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 39 additions and 2 deletions

View File

@ -4042,6 +4042,7 @@ export interface ExperimentsExtra {
* Compile entrypoints and import()s only when they are accessed.
*/
lazyCompilation?: boolean | LazyCompilationOptions;
[k: string]: any;
}
/**
* Enables/Disables experiments (experimental features with relax SemVer compatibility).

File diff suppressed because one or more lines are too long

View File

@ -965,7 +965,7 @@
"description": "Enables/Disables experiments (experimental features with relax SemVer compatibility).",
"type": "object",
"implements": ["#/definitions/ExperimentsCommon"],
"additionalProperties": false,
"additionalProperties": true,
"properties": {
"asyncWebAssembly": {
"description": "Support WebAssembly as asynchronous EcmaScript Module.",

View File

@ -51,6 +51,30 @@ describe("Validation", () => {
});
};
const createTestCaseWithoutError = (name, config, fn) => {
it(`should success validation for ${name}`, () => {
let errored;
try {
const webpack = require("..");
webpack(config);
} catch (err) {
if (err.name === "ValidationError") {
throw new Error("Validation didn't success");
}
errored = err;
return;
}
if (errored) {
throw new Error("Validation didn't success");
}
});
};
createTestCase("undefined configuration", undefined, (msg) =>
expect(msg).toMatchInlineSnapshot(`
"Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
@ -626,6 +650,10 @@ describe("Validation", () => {
`)
);
createTestCaseWithoutError("experiments", {
experiments: { unknown: true }
});
describe("did you mean", () => {
createTestCase(
"module.rules",
@ -641,6 +669,7 @@ describe("Validation", () => {
Did you mean module.rules?"
`)
);
createTestCase(
"optimization.splitChunks",
{
@ -655,6 +684,7 @@ describe("Validation", () => {
Did you mean optimization.splitChunks?"
`)
);
createTestCase(
"module.noParse",
{
@ -669,6 +699,7 @@ describe("Validation", () => {
Did you mean module.noParse?"
`)
);
createTestCase(
"optimization.moduleIds",
{
@ -685,6 +716,7 @@ describe("Validation", () => {
Did you mean optimization.moduleIds: \\"hashed\\" (BREAKING CHANGE since webpack 5)?"
`)
);
createTestCase(
"optimization.chunkIds",
{
@ -701,6 +733,7 @@ describe("Validation", () => {
Did you mean optimization.chunkIds: \\"named\\" (BREAKING CHANGE since webpack 5)?"
`)
);
createTestCase(
"optimization.chunk/moduleIds",
{
@ -717,6 +750,7 @@ describe("Validation", () => {
Did you mean optimization.chunkIds: \\"size\\" and optimization.moduleIds: \\"size\\" (BREAKING CHANGE since webpack 5)?"
`)
);
createTestCase(
"optimization.idHint",
{

2
types.d.ts vendored
View File

@ -4903,6 +4903,8 @@ declare interface ExperimentsCommon {
* Enables/Disables experiments (experimental features with relax SemVer compatibility).
*/
declare interface ExperimentsExtra {
[index: string]: any;
/**
* Build http(s): urls using a lockfile and resource content cache.
*/