@@ -11,7 +11,7 @@ export default function loader(source, map) {
1111 const parseResult = parse ( source ) ;
1212
1313 let replacer ;
14- if ( options . sourceMap ) {
14+ if ( options . sourceMap ) {
1515 replacer = new ReplaceSource (
1616 map ? new SourceMapSource ( source , remainingRequest , map ) : new OriginalSource ( source , remainingRequest ) ,
1717 remainingRequest ) ;
@@ -23,7 +23,7 @@ export default function loader(source, map) {
2323 const includedStylesheetsMediaQuery = new Map ( ) ;
2424
2525 parseResult . atImports . forEach ( ( imp ) => {
26- if ( loaderUtils . isUrlRequest ( imp . url , options . root ) ) {
26+ if ( loaderUtils . isUrlRequest ( imp . url , options . root ) ) {
2727 const request = loaderUtils . urlToRequest ( imp . url , options . root ) ;
2828 replacer . replace ( imp . start , imp . end , '' ) ;
2929 includedStylesheets . add ( request ) ;
@@ -42,21 +42,21 @@ export default function loader(source, map) {
4242 const importReplacements = new Map ( ) ;
4343
4444 let id = 0 ;
45- for ( const pair of importedNames ) {
45+ for ( const pair of importedNames ) {
4646 const internalName = `cssLoaderImport${ id } _${ pair [ 1 ] . importName } ` ;
4747 id += 1 ;
4848 importReplacements . set ( pair [ 0 ] , internalName ) ;
4949 declarations . push ( `import { ${ pair [ 1 ] . importName } as ${ internalName } } from ${ JSON . stringify ( pair [ 1 ] . from ) } ;` ) ;
5050 includedStylesheets . add ( pair [ 1 ] . from ) ;
5151 }
5252
53- for ( const pair of importReplacements ) {
53+ for ( const pair of importReplacements ) {
5454 const identifier = parseResult . identifiers . get ( pair [ 0 ] ) ;
55- if ( identifier ) {
55+ if ( identifier ) {
5656 columns = false ;
57- const length = identifier . name . length ;
57+ const offset = identifier . name . length - 1 ;
5858 identifier . locations . forEach ( ( loc ) => {
59- replacer . replace ( loc , loc + length - 1 , `$CSS$LOADER$\{${ pair [ 1 ] } }` ) ;
59+ replacer . replace ( loc , loc + offset , `$CSS$LOADER$\{${ pair [ 1 ] } }` ) ;
6060 } ) ;
6161 }
6262 }
@@ -66,21 +66,21 @@ export default function loader(source, map) {
6666 } ) ;
6767
6868 const includedStylesheetsArray = [ ] ;
69- for ( const include of includedStylesheets ) {
69+ for ( const include of includedStylesheets ) {
7070 const internalName = `cssLoaderImport${ id } ` ;
7171 id += 1 ;
7272 declarations . push ( `import ${ internalName } from ${ loaderUtils . stringifyRequest ( this , include ) } ;` ) ;
7373 includedStylesheetsArray . push ( {
7474 name : internalName ,
75- mediaQuery : includedStylesheetsMediaQuery . get ( include ) || ''
75+ mediaQuery : includedStylesheetsMediaQuery . get ( include ) || '' ,
7676 } ) ;
7777 }
7878
7979 let css ;
8080 let sourceMap ;
81- if ( options . sourceMap ) {
81+ if ( options . sourceMap ) {
8282 const sourceAndMap = replacer . sourceAndMap ( typeof options . sourceMap === 'object' ? options . sourceMap : {
83- columns : columns
83+ columns,
8484 } ) ;
8585 css = sourceAndMap . code ;
8686 sourceMap = sourceAndMap . map ;
@@ -93,22 +93,20 @@ export default function loader(source, map) {
9393
9494 return [
9595 '// css runtime' ,
96- `import * as runtime from ${ loaderUtils . stringifyRequest ( this , require . resolve ( " ../runtime" ) ) } ;` ,
96+ `import * as runtime from ${ loaderUtils . stringifyRequest ( this , require . resolve ( ' ../runtime' ) ) } ;` ,
9797 '' ,
9898 '// declarations' ,
9999 declarations . join ( '\n' ) ,
100100 '' ,
101101 '// CSS' ,
102- 'export default runtime.create([' ,
102+ 'export default /*#__PURE__*/ runtime.create([' ,
103103 ] . concat (
104104 includedStylesheetsArray . map ( ( include ) => {
105- if ( ! include . mediaQuery ) return ` ${ include . name } ,` ;
105+ if ( ! include . mediaQuery ) return ` ${ include . name } ,` ;
106106 return ` runtime.importStylesheet(${ include . name } , ${ JSON . stringify ( include . mediaQuery ) } ,` ;
107- } )
107+ } ) ,
108108 ) . concat ( [
109- sourceMap ?
110- ` runtime.moduleWithSourceMap(module.id, ${ cssJs } , ${ sourceMap } )` :
111- ` runtime.moduleWithoutSourceMap(module.id, ${ cssJs } )` ,
112- ']);'
109+ ` runtime.${ sourceMap ? 'moduleWithSourceMap' : 'moduleWithoutSourceMap' } (module.id, ${ cssJs } ${ sourceMap ? `, ${ sourceMap } ` : '' } )` ,
110+ ']);' ,
113111 ] ) . join ( '\n' ) ;
114112}
0 commit comments