Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 33b306b

Browse files
SevInfmzgoddard
authored andcommitted
fix: memory leak in TransformNormalModuleFactoryPlugin (mzgoddard#414)
Problem: plugin wraps createLoaderContext without checking if it was already done before. As a result, in a watch mode more and more wrappers get added on top of the function and eat more and more memory. Fixed by saving original function on module instance itself and wrapping saved function instead.
1 parent e370f1f commit 33b306b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

‎lib/TransformNormalModuleFactoryPlugin.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ class NormalModuleFactoryPlugin {
3838
'HardSource - TransformNormalModuleFactoryPlugin',
3939
module => {
4040
if (module.constructor.name === 'NormalModule') {
41-
const _createLoaderContext = module.createLoaderContext;
41+
module.__originalCreateLoaderContext =
42+
module.__originalCreateLoaderContext ||
43+
module.createLoaderContext;
4244
module.__hardSource_resolved = {};
4345
module.createLoaderContext = (...args) => {
44-
const loaderContext = _createLoaderContext.call(
45-
module,
46+
const loaderContext = module.__originalCreateLoaderContext(
4647
...args,
4748
);
4849
const _resolve = loaderContext.resolve;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /