webpack/webpack · error · Error
JavascriptModulesPlugin error: JavascriptModulesPlugin.getCo
Error message
JavascriptModulesPlugin error: JavascriptModulesPlugin.getCompilationHooks().renderContent plugins should return something
What it means
Thrown during renderChunk (the non-entry chunk render path in JavascriptModulesPlugin) when the renderContent SyncWaterfallHook returns a falsy value after being called. The hook chains plugin outputs; if the last plugin to tap returns null/undefined (and no plugin returned a valid Source), the post-hook check throws.
Source
Thrown at lib/javascript/JavascriptModulesPlugin.js:1070
chunkRenderContext,
registryModules,
(module, renderInObject) =>
this.renderModule(
module,
{ ...chunkRenderContext, factory: true, renderInObject },
hooks
)
) || new RawSource("{}");
let source = tryRunOrWebpackError(
() => hooks.renderChunk.call(moduleSources, chunkRenderContext),
"JavascriptModulesPlugin.getCompilationHooks().renderChunk"
);
source = tryRunOrWebpackError(
() => hooks.renderContent.call(source, chunkRenderContext),
"JavascriptModulesPlugin.getCompilationHooks().renderContent"
);
if (!source) {
throw new Error(
"JavascriptModulesPlugin error: JavascriptModulesPlugin.getCompilationHooks().renderContent plugins should return something"
);
}
source = InitFragment.addToSource(
source,
chunkRenderContext.chunkInitFragments,
chunkRenderContext
);
source = tryRunOrWebpackError(
() => hooks.render.call(source, chunkRenderContext),
"JavascriptModulesPlugin.getCompilationHooks().render"
);
if (!source) {
throw new Error(
"JavascriptModulesPlugin error: JavascriptModulesPlugin.getCompilationHooks().render plugins should return something"
);
}
chunk.rendered = true;View on GitHub (pinned to 318421ea8a)
Solutions
- Ensure your renderContent tap always returns a Source (or the input source unchanged) — never null or undefined.
- Return the incoming `source` argument as a pass-through when your plugin has no transformation to apply.
- Audit all plugins tapping renderContent to find which one returns falsy for the failing chunk.
- If a third-party plugin is responsible, check for an updated version compatible with your webpack major.
Example fix
// before
hooks.renderContent.tap('MyPlugin', (source, ctx) => {
return transformOrNull(source); // may return null
});
// after
hooks.renderContent.tap('MyPlugin', (source, ctx) => {
return transformOrNull(source) || source;
}); Defensive patterns
Strategy: validation
Validate before calling
// When tapping renderContent, always guarantee a return
hooks.renderContent.tap('MyPlugin', (source, ctx) => {
const result = myTransform(source);
return result !== null && result !== undefined ? result : source;
}); Prevention
- Always return a Source from renderContent taps.
- Use `return source;` as the default fallback in taps.
- Test plugins against both entry and non-entry chunks.
When it happens
Trigger: A plugin tapping JavascriptModulesPlugin.getCompilationHooks().renderContent for a non-entry chunk returns null, undefined, or an empty string instead of a Source object, and no other plugin in the chain provides a valid Source.
Common situations: Custom render plugins (minification wrappers, source transform plugins) that conditionally return nothing; a plugin authored for entry chunks only that inadvertently taps renderContent for all chunks; version incompatibility where a plugin's render logic changed.
Related errors
- JavascriptModulesPlugin error: JavascriptModulesPlugin.getCo
- JavascriptModulesPlugin error: JavascriptModulesPlugin.getCo
- Module.entryModule: Multiple entry modules are not supported
- No code generation entry for ${module.identifier()} (existin
- No unique code generation entry for unspecified runtime for
AI-assisted analysis of webpack/webpack@318421ea8a (2026-08-03).
Data as JSON: /data/errors/eb1f4cce6c38b4d5.json.
Report an issue: GitHub.