Skip to content

Commit acb6685

Browse files
committed
removed shared util
1 parent 73ee1c8 commit acb6685

File tree

3 files changed

+7
-34
lines changed

3 files changed

+7
-34
lines changed

src/index.js

+3-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { validate } from 'schema-utils';
44

55
import schema from './plugin-options.json';
6-
import { shared, MODULE_TYPE, compareModulesByIdentifier } from './utils';
6+
import { MODULE_TYPE, compareModulesByIdentifier } from './utils';
77

88
const pluginName = 'mini-css-extract-plugin';
99

@@ -381,16 +381,8 @@ class MiniCssExtractPlugin {
381381
}
382382
}
383383

384-
// initializeCssDependency
385-
// eslint-disable-next-line no-shadow
386-
const { CssModule, CssDependency } = shared(webpack, (webpack) => {
387-
// eslint-disable-next-line no-shadow
388-
const CssModule = MiniCssExtractPlugin.getCssModule(webpack);
389-
// eslint-disable-next-line no-shadow
390-
const CssDependency = MiniCssExtractPlugin.getCssDependency(webpack);
391-
392-
return { CssModule, CssDependency };
393-
});
384+
const CssModule = MiniCssExtractPlugin.getCssModule(webpack);
385+
const CssDependency = MiniCssExtractPlugin.getCssDependency(webpack);
394386

395387
compiler.hooks.thisCompilation.tap(pluginName, (compilation) => {
396388
class CssModuleFactory {

src/loader.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import path from 'path';
33
import loaderUtils from 'loader-utils';
44
import { validate } from 'schema-utils';
55

6-
import { shared, findModuleById, evalModuleCode } from './utils';
6+
import { findModuleById, evalModuleCode } from './utils';
77
import schema from './loader-options.json';
88

9+
import MiniCssExtractPlugin from './index';
10+
911
const pluginName = 'mini-css-extract-plugin';
1012

1113
function hotLoader(content, context) {
@@ -199,9 +201,7 @@ export function pitch(request) {
199201
}
200202

201203
const count = identifierCountMap.get(dependency.identifier) || 0;
202-
const { CssDependency } = shared(webpack, () => {
203-
return {};
204-
});
204+
const { CssDependency } = MiniCssExtractPlugin.getCssDependency(webpack)
205205

206206
if (!CssDependency) {
207207
throw new Error(

src/utils.js

-19
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,7 @@ function compareModulesByIdentifier(a, b) {
4949
return compareIds(a.identifier(), b.identifier());
5050
}
5151

52-
const initializeCache = new WeakMap();
53-
54-
function shared(webpack, initializer) {
55-
const cacheEntry = initializeCache.get(webpack);
56-
57-
// eslint-disable-next-line no-undefined
58-
if (cacheEntry !== undefined) {
59-
return cacheEntry;
60-
}
61-
62-
const constructors = initializer(webpack);
63-
const result = { ...constructors };
64-
65-
initializeCache.set(webpack, result);
66-
67-
return result;
68-
}
69-
7052
export {
71-
shared,
7253
MODULE_TYPE,
7354
findModuleById,
7455
evalModuleCode,

0 commit comments

Comments
 (0)