Skip to content

Commit c79f2cf

Browse files
authored
fix: memoy leak (#1836)
1 parent 7effc30 commit c79f2cf

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/child-compiler.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
/** @typedef {import("webpack").sources.Source} Source */
1414
/** @typedef {{hash: string, entry: Chunk, content: string, assets: {[name: string]: { source: Source, info: import("webpack").AssetInfo }}}} ChildCompilationTemplateResult */
1515

16-
let instanceId = 0;
1716
/**
1817
* The HtmlWebpackChildCompiler is a helper to allow reusing one childCompiler
1918
* for multiple HtmlWebpackPlugin instances to improve the compilation performance.
@@ -24,8 +23,6 @@ class HtmlWebpackChildCompiler {
2423
* @param {string[]} templates
2524
*/
2625
constructor (templates) {
27-
/** Id for this ChildCompiler */
28-
this.id = instanceId++;
2926
/**
3027
* @type {string[]} templateIds
3128
* The template array will allow us to keep track which input generated which output
@@ -110,12 +107,12 @@ class HtmlWebpackChildCompiler {
110107
childCompiler.context = mainCompilation.compiler.context;
111108

112109
// Generate output file names
113-
const temporaryTemplateNames = this.templates.map((template, index) => `__child-HtmlWebpackPlugin_${index}-${this.id}`);
110+
const temporaryTemplateNames = this.templates.map((template, index) => `__child-HtmlWebpackPlugin_${index}-${template}`);
114111

115112
// Add all templates
116113
this.templates.forEach((template, index) => {
117-
new EntryPlugin(childCompiler.context, 'data:text/javascript,__webpack_public_path__ = __webpack_base_uri__ = htmlWebpackPluginPublicPath;', `HtmlWebpackPlugin_${index}-${this.id}`).apply(childCompiler);
118-
new EntryPlugin(childCompiler.context, template, `HtmlWebpackPlugin_${index}-${this.id}`).apply(childCompiler);
114+
new EntryPlugin(childCompiler.context, 'data:text/javascript,__webpack_public_path__ = __webpack_base_uri__ = htmlWebpackPluginPublicPath;', `HtmlWebpackPlugin_${index}-${template}`).apply(childCompiler);
115+
new EntryPlugin(childCompiler.context, template, `HtmlWebpackPlugin_${index}-${template}`).apply(childCompiler);
119116
});
120117

121118
// The templates are compiled and executed by NodeJS - similar to server side rendering

0 commit comments

Comments
 (0)