Skip to content

fix: allow consumers to access CssModule #703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Feb 25, 2021
Prev Previous commit
Next Next commit
fix lint error
  • Loading branch information
barak007 committed Feb 19, 2021
commit 8be876f85df193a79132ad5a4a44029c4dfee5e3
14 changes: 7 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ class MiniCssExtractPlugin {
return usedModules;
}

modules = [...modules];
const modulesList = [...modules];

const [chunkGroup] = chunk.groupsIterable;
const moduleIndexFunctionName =
Expand All @@ -1116,16 +1116,16 @@ class MiniCssExtractPlugin {

if (typeof chunkGroup[moduleIndexFunctionName] === 'function') {
// Store dependencies for modules
const moduleDependencies = new Map(modules.map((m) => [m, new Set()]));
const moduleDependencies = new Map(modulesList.map((m) => [m, new Set()]));
const moduleDependenciesReasons = new Map(
modules.map((m) => [m, new Map()])
modulesList.map((m) => [m, new Map()])
);

// Get ordered list of modules per chunk group
// This loop also gathers dependencies from the ordered lists
// Lists are in reverse order to allow to use Array.pop()
const modulesByChunkGroup = Array.from(chunk.groupsIterable, (cg) => {
const sortedModules = modules
const sortedModules = modulesList
.map((m) => {
return {
module: m,
Expand Down Expand Up @@ -1158,7 +1158,7 @@ class MiniCssExtractPlugin {

const unusedModulesFilter = (m) => !usedModules.has(m);

while (usedModules.size < modules.length) {
while (usedModules.size < modulesList.length) {
let success = false;
let bestMatch;
let bestMatchDeps;
Expand Down Expand Up @@ -1240,8 +1240,8 @@ class MiniCssExtractPlugin {
// (to avoid a breaking change)
// TODO remove this in next major version
// and increase minimum webpack version to 4.12.0
modules.sort((a, b) => a.index2 - b.index2);
usedModules = modules;
modulesList.sort((a, b) => a.index2 - b.index2);
usedModules = modulesList;
}

this._sortedModulesCache.set(chunk, usedModules);
Expand Down