diff --git a/lib/Module.js b/lib/Module.js index 64e94b73e..b07066f38 100644 --- a/lib/Module.js +++ b/lib/Module.js @@ -200,7 +200,7 @@ class Module extends DependenciesBlock { /** @type {boolean} */ this.useSimpleSourceMap = false; - // Is hot context + // Is in hot context, i.e. HotModuleReplacementPlugin.js enabled /** @type {boolean} */ this.hot = false; // Info from Build diff --git a/lib/css/CssModulesPlugin.js b/lib/css/CssModulesPlugin.js index fcc0a773f..42982e066 100644 --- a/lib/css/CssModulesPlugin.js +++ b/lib/css/CssModulesPlugin.js @@ -189,7 +189,7 @@ class CssModulesPlugin { constructor() { /** @type {WeakMap} */ - this._moduleCache = new WeakMap(); + this._moduleFactoryCache = new WeakMap(); } /** @@ -717,8 +717,7 @@ class CssModulesPlugin { * @returns {Source} css module source */ renderModule(module, renderContext, hooks) { - const { codeGenerationResults, chunk, undoPath, chunkGraph } = - renderContext; + const { codeGenerationResults, chunk, undoPath } = renderContext; const codeGenResult = codeGenerationResults.get(module, chunk.runtime); const moduleSourceContent = /** @type {Source} */ @@ -726,8 +725,7 @@ class CssModulesPlugin { codeGenResult.sources.get("css") || codeGenResult.sources.get("css-import") ); - - const cacheEntry = this._moduleCache.get(moduleSourceContent); + const cacheEntry = this._moduleFactoryCache.get(moduleSourceContent); /** @type {Inheritance} */ const inheritance = [[module.cssLayer, module.supports, module.media]]; @@ -749,9 +747,9 @@ class CssModulesPlugin { ) { source = cacheEntry.source; } else { - const moduleSourceCode = /** @type {string} */ ( - moduleSourceContent.source() - ); + const moduleSourceCode = + /** @type {string} */ + (moduleSourceContent.source()); const publicPathAutoRegex = new RegExp( CssUrlDependency.PUBLIC_PATH_AUTO, "g" @@ -803,18 +801,12 @@ class CssModulesPlugin { } source = new CachedSource(moduleSource); - this._moduleCache.set(moduleSourceContent, { + this._moduleFactoryCache.set(moduleSourceContent, { inheritance, undoPath, source }); } - let moduleId = String(chunkGraph.getModuleId(module)); - - // When `optimization.moduleIds` is `named` the module id is a path, so we need to normalize it between platforms - if (typeof moduleId === "string") { - moduleId = moduleId.replace(/\\/g, "/"); - } return tryRunOrWebpackError( () => hooks.renderModulePackage.call(source, module, renderContext),