33import webpack from 'webpack' ;
44import sources from 'webpack-sources' ;
55
6+ import CssDependency from './CssDependency' ;
7+
68const { ConcatSource, SourceMapSource, OriginalSource } = sources ;
79const {
810 Template,
@@ -19,27 +21,6 @@ const REGEXP_NAME = /\[name\]/i;
1921const REGEXP_PLACEHOLDERS = / \[ ( n a m e | i d | c h u n k h a s h ) \] / g;
2022const DEFAULT_FILENAME = '[name].css' ;
2123
22- class CssDependency extends webpack . Dependency {
23- constructor (
24- { identifier, content, media, sourceMap } ,
25- context ,
26- identifierIndex
27- ) {
28- super ( ) ;
29-
30- this . identifier = identifier ;
31- this . identifierIndex = identifierIndex ;
32- this . content = content ;
33- this . media = media ;
34- this . sourceMap = sourceMap ;
35- this . context = context ;
36- }
37-
38- getResourceIdentifier ( ) {
39- return `css-module-${ this . identifier } -${ this . identifierIndex } ` ;
40- }
41- }
42-
4324class CssDependencyTemplate {
4425 apply ( ) { }
4526}
@@ -148,30 +129,6 @@ class MiniCssExtractPlugin {
148129
149130 apply ( compiler ) {
150131 compiler . hooks . thisCompilation . tap ( pluginName , ( compilation ) => {
151- compilation . hooks . normalModuleLoader . tap ( pluginName , ( lc , m ) => {
152- const loaderContext = lc ;
153- const module = m ;
154-
155- loaderContext [ MODULE_TYPE ] = ( content ) => {
156- if ( ! Array . isArray ( content ) && content != null ) {
157- throw new Error (
158- `Exported value was not extracted as an array: ${ JSON . stringify (
159- content
160- ) } `
161- ) ;
162- }
163-
164- const identifierCountMap = new Map ( ) ;
165-
166- for ( const line of content ) {
167- const count = identifierCountMap . get ( line . identifier ) || 0 ;
168-
169- module . addDependency ( new CssDependency ( line , m . context , count ) ) ;
170- identifierCountMap . set ( line . identifier , count + 1 ) ;
171- }
172- } ;
173- } ) ;
174-
175132 compilation . dependencyFactories . set (
176133 CssDependency ,
177134 new CssModuleFactory ( )
0 commit comments