@@ -59,7 +59,12 @@ const transpile = function(source, options) {
5959 hideStack = true ;
6060 }
6161 throw new BabelLoaderError (
62- name , message , error . codeFrame , hideStack , error ) ;
62+ name ,
63+ message ,
64+ error . codeFrame ,
65+ hideStack ,
66+ error ,
67+ ) ;
6368 } else {
6469 throw error ;
6570 }
@@ -97,7 +102,9 @@ function passMetadata(s, context, metadata) {
97102
98103module . exports = function ( source , inputSourceMap ) {
99104 // Handle filenames (#106)
100- const webpackRemainingChain = loaderUtils . getRemainingRequest ( this ) . split ( "!" ) ;
105+ const webpackRemainingChain = loaderUtils
106+ . getRemainingRequest ( this )
107+ . split ( "!" ) ;
101108 const filename = webpackRemainingChain [ webpackRemainingChain . length - 1 ] ;
102109
103110 // Handle options
@@ -110,10 +117,13 @@ module.exports = function(source, inputSourceMap) {
110117 cacheIdentifier : JSON . stringify ( {
111118 "babel-loader" : pkg . version ,
112119 "babel-core" : babel . version ,
113- babelrc : exists ( loaderOptions . babelrc ) ?
114- read ( loaderOptions . babelrc ) :
115- resolveRc ( path . dirname ( filename ) ) ,
116- env : loaderOptions . forceEnv || process . env . BABEL_ENV || process . env . NODE_ENV || "development" ,
120+ babelrc : exists ( loaderOptions . babelrc )
121+ ? read ( loaderOptions . babelrc )
122+ : resolveRc ( path . dirname ( filename ) ) ,
123+ env : loaderOptions . forceEnv ||
124+ process . env . BABEL_ENV ||
125+ process . env . NODE_ENV ||
126+ "development" ,
117127 } ) ,
118128 } ;
119129
@@ -124,10 +134,7 @@ module.exports = function(source, inputSourceMap) {
124134 }
125135
126136 if ( options . sourceFileName === undefined ) {
127- options . sourceFileName = relative (
128- options . sourceRoot ,
129- options . filename
130- ) ;
137+ options . sourceFileName = relative ( options . sourceRoot , options . filename ) ;
131138 }
132139
133140 const cacheDirectory = options . cacheDirectory ;
@@ -140,24 +147,27 @@ module.exports = function(source, inputSourceMap) {
140147
141148 if ( cacheDirectory ) {
142149 const callback = this . async ( ) ;
143- return cache ( {
144- directory : cacheDirectory ,
145- identifier : cacheIdentifier ,
146- source : source ,
147- options : options ,
148- transform : transpile ,
149- } , ( err , { code, map, metadata } = { } ) => {
150- if ( err ) return callback ( err ) ;
151-
152- metadataSubscribers . forEach ( ( s ) => passMetadata ( s , this , metadata ) ) ;
153-
154- return callback ( null , code , map ) ;
155- } ) ;
150+ return cache (
151+ {
152+ directory : cacheDirectory ,
153+ identifier : cacheIdentifier ,
154+ source : source ,
155+ options : options ,
156+ transform : transpile ,
157+ } ,
158+ ( err , { code, map, metadata } = { } ) => {
159+ if ( err ) return callback ( err ) ;
160+
161+ metadataSubscribers . forEach ( s => passMetadata ( s , this , metadata ) ) ;
162+
163+ return callback ( null , code , map ) ;
164+ } ,
165+ ) ;
156166 }
157167
158168 const { code, map, metadata } = transpile ( source , options ) ;
159169
160- metadataSubscribers . forEach ( ( s ) => passMetadata ( s , this , metadata ) ) ;
170+ metadataSubscribers . forEach ( s => passMetadata ( s , this , metadata ) ) ;
161171
162172 this . callback ( null , code , map ) ;
163173} ;
0 commit comments