Experiments

experiments

boolean: false

experiments option was introduced in webpack 5 to empower users with the ability to activate and try out experimental features.

Because experimental features have relaxed semantic versioning and might contain breaking changes, make sure to fix webpack's version to minor e.g. webpack: ~5.4.3 instead of webpack: ^5.4.3 or use a lockfile when using experiments.

Available options:

  • mjs: Support .mjs files as a way to define EcmaScript modules
  • syncWebAssembly: Support the old WebAssembly like in webpack 4
  • asyncWebAssembly: Support the new WebAssembly according to the updated specification, it makes a WebAssembly module an async module
  • topLevelAwait: Support the Top Level Await Stage 3 proposal, it makes the module an async module when await is used on the top-level
  • asset: a type of module that allows to use asset files (fonts, images, etc) without configuring loaders to handle their importing, similar to file-loader | url-loader | raw-loader
  • outputModule: 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'.

webpack.config.js

module.exports = {
  //...
  experiments: {
    mjs: true,
    outputModule: true,
    syncWebAssembly: true,
    topLevelAwait: true,
    asset: true,
    asyncWebAssembly: true,
  },
};