experiments
boolean: false
experiments
option was introduced in webpack 5 to empower users with the ability to activate and try out experimental features.
Available options:
syncWebAssembly
: Support the old WebAssembly like in webpack 4asyncWebAssembly
: Support the new WebAssembly according to the updated specification, it makes a WebAssembly module an async moduletopLevelAwait
: Support the Top Level Await Stage 3 proposal, it makes the module an async module when await
is used on the top-leveloutputModule
: enables the use of output.module
configuration option and sets it to true
. Enables the use of output.libraryTarget
as 'module'
and sets it to 'module'
.layers
: Enable module and chunk layers.webpack.config.js
module.exports = {
//...
experiments: {
outputModule: true,
syncWebAssembly: true,
topLevelAwait: true,
asyncWebAssembly: true,
layers: true,
lazyCompilation: true,
},
};
Compile entrypoints and dynamic import
s only when they are accessed.
boolean
object
{
// define a custom backend
backend?: ((
compiler: webpack.Compiler,
client: string,
callback: (err?: Error, api?: any) => void
) => void)
| ((
compiler: webpack.Compiler,
client: string
) => Promise<any>),
client?: string, // define a custom client
entries?: boolean // enable lazy compilation for entries
}
module.exports = {
// β¦
experiments: {
lazyCompilation: true,
},
};