{"id":"e909b54609bfadb6","repo":"webpack/webpack","slug":"library-type-type-is-not-enabled-enablewasml","errorCode":null,"errorMessage":"Library type \"${type}\" is not enabled. EnableWasmLoadingPlugin need to be used to enable this type of wasm loading. This usually happens through the \"output.enabledWasmLoadingTypes\" option. If you are using a function as entry which sets \"wasmLoading\", you need to add all potential library types to \"output.enabledWasmLoadingTypes\". These types are enabled: ${[...getEnabledTypes(compiler)].join(\", \")}","messagePattern":"Library type \"(.+?)\" is not enabled\\. EnableWasmLoadingPlugin need to be used to enable this type of wasm loading\\. This usually happens through the \"output\\.enabledWasmLoadingTypes\" option\\. If you are using a function as entry which sets \"wasmLoading\", you need to add all potential library types to \"output\\.enabledWasmLoadingTypes\"\\. These types are enabled: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/wasm/EnableWasmLoadingPlugin.js","lineNumber":67,"sourceCode":"\t * without applying additional built-in behavior.\n\t * @param {Compiler} compiler the compiler instance\n\t * @param {WasmLoadingType} type type of library\n\t * @returns {void}\n\t */\n\tstatic setEnabled(compiler, type) {\n\t\tgetEnabledTypes(compiler).add(type);\n\t}\n\n\t/**\n\t * Verifies that a wasm loading type has been enabled before code generation\n\t * attempts to use it.\n\t * @param {Compiler} compiler the compiler instance\n\t * @param {WasmLoadingType} type type of library\n\t * @returns {void}\n\t */\n\tstatic checkEnabled(compiler, type) {\n\t\tif (!getEnabledTypes(compiler).has(type)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Library type \"${type}\" is not enabled. ` +\n\t\t\t\t\t\"EnableWasmLoadingPlugin need to be used to enable this type of wasm loading. \" +\n\t\t\t\t\t'This usually happens through the \"output.enabledWasmLoadingTypes\" option. ' +\n\t\t\t\t\t'If you are using a function as entry which sets \"wasmLoading\", you need to add all potential library types to \"output.enabledWasmLoadingTypes\". ' +\n\t\t\t\t\t`These types are enabled: ${[...getEnabledTypes(compiler)].join(\", \")}`\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Enables the requested wasm loading backend once and applies the\n\t * environment-specific plugins that provide its parser, generator, and\n\t * runtime support.\n\t * @param {Compiler} compiler the compiler instance\n\t * @returns {void}\n\t */\n\tapply(compiler) {\n\t\tconst { type } = this;","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/webpack/webpack/blob/318421ea8ac81371f5171236a6efb63675576528/lib/wasm/EnableWasmLoadingPlugin.js#L49-L85","documentation":"Before emitting wasm-loading runtime code webpack calls EnableWasmLoadingPlugin.checkEnabled(compiler, type) to confirm the requested backend was registered for this compiler. A chunk or entry can request a wasm loading type via entry.wasmLoading or via runtime requirements; if that type was never added to output.enabledWasmLoadingTypes (or applied through the plugin), the build aborts and lists the types that ARE enabled so the mismatch is obvious.","triggerScenarios":"Setting wasmLoading on an entry (or via target) to 'fetch'/'async-node'/'universal' without listing it in output.enabledWasmLoadingTypes; using a function entry that returns different wasmLoading values per runtime without pre-enabling every possible value; a plugin that taps wasm runtime requirements without applying the matching EnableWasmLoadingPlugin.","commonSituations":"Multi-compiler build where one compiler sets a wasm type not enabled in the shared config; upgrading webpack and relying on a type that used to be default-enabled; target arrays (e.g. ['web','node']) or Module Federation introducing a runtime whose default wasm loading type was not pre-enabled.","solutions":["Add the missing type to output.enabledWasmLoadingTypes (e.g. ['fetch','async-node']).","If you use a function entry that sets wasmLoading, enumerate every type the function can return and add all of them to output.enabledWasmLoadingTypes.","For a custom wasm loading backend, apply EnableWasmLoadingPlugin for your type (or call EnableWasmLoadingPlugin.setEnabled(compiler, type)) inside your plugin's apply()."],"exampleFix":"// before\nmodule.exports = {\n  output: { enabledWasmLoadingTypes: ['fetch'] },\n  entry: { main: () => ({ wasmLoading: 'async-node', import: './app' }) }\n};\n\n// after\nmodule.exports = {\n  output: { enabledWasmLoadingTypes: ['fetch', 'async-node'] },\n  entry: { main: () => ({ wasmLoading: 'async-node', import: './app' }) }\n};","handlingStrategy":"validation","validationCode":"// Validate config before running the compiler: every wasmLoading value any\n// entry can produce must appear in output.enabledWasmLoadingTypes.\nconst KNOWN = new Set(['fetch', 'async-node', 'universal']);\nfunction validateWasmLoading(config) {\n  const enabled = new Set(config.output?.enabledWasmLoadingTypes ?? []);\n  const seen = new Set();\n  const visit = (entry) => {\n    if (!entry) return;\n    if (typeof entry === 'string') return;\n    if (Array.isArray(entry)) return entry.forEach(visit);\n    if (typeof entry === 'function') return; // cannot statically know — see tip\n    if (entry.wasmLoading) seen.add(entry.wasmLoading);\n    if (Array.isArray(entry.import)) entry.import.forEach(visit);\n  };\n  Object.values(config.entry ?? {}).forEach(visit);\n  for (const t of seen) {\n    if (!KNOWN.has(t) && !enabled.has(t)) {\n      throw new Error(`wasmLoading '${t}' is used by an entry but missing from output.enabledWasmLoadingTypes`);\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["For function entries that set wasmLoading, add every possible return value to output.enabledWasmLoadingTypes — the error message itself lists what is enabled, use it as the diff target.","In a multi-compiler setup, set output.enabledWasmLoadingTypes per child compiler rather than relying on a shared default.","When writing a plugin that introduces a new wasm loading backend, call EnableWasmLoadingPlugin.setEnabled(compiler, type) so checkEnabled never sees it as missing."],"tags":["wasm","configuration","wasm-loading","multi-compiler"],"analyzedSha":"318421ea8ac81371f5171236a6efb63675576528","analyzedAt":"2026-08-03T19:39:56.731Z","schemaVersion":2}