1
- var path = require ( ' path' ) ;
2
- var DtsCreator = require ( ' typed-css-modules' ) ;
3
- var loaderUtils = require ( ' loader-utils' ) ;
1
+ var path = require ( " path" ) ;
2
+ var DtsCreator = require ( " typed-css-modules" ) ;
3
+ var loaderUtils = require ( " loader-utils" ) ;
4
4
5
5
module . exports = function ( source , map ) {
6
6
this . cacheable && this . cacheable ( ) ;
@@ -13,7 +13,7 @@ module.exports = function(source, map) {
13
13
var options = loaderUtils . getOptions ( this ) || { } ;
14
14
var context = options . context || this . context || this . rootContext ;
15
15
var emitFile = ! options . noEmit ;
16
-
16
+
17
17
// Make sure to not modify options object directly
18
18
var creatorOptions = Object . assign ( { } , options ) ;
19
19
delete creatorOptions . noEmit ;
@@ -22,13 +22,21 @@ module.exports = function(source, map) {
22
22
23
23
// creator.create(..., source) tells the module to operate on the
24
24
// source variable. Check API for more details.
25
- creator . create ( this . resourcePath , source ) . then ( content => {
26
- if ( emitFile ) {
25
+ creator
26
+ . create ( this . resourcePath , source )
27
+ . then ( content => {
28
+ if ( emitFile ) {
27
29
// Emit the created content as well
28
- this . emitFile ( path . relative ( context , content . outputFilePath ) , content . contents || [ '' ] , map ) ;
29
- }
30
- content . writeFile ( ) . then ( _ => {
31
- callback ( null , source , map ) ;
32
- } ) ;
33
- } ) ;
30
+ this . emitFile (
31
+ path . relative ( context , content . outputFilePath ) ,
32
+ content . contents || [ "" ] ,
33
+ map
34
+ ) ;
35
+ }
36
+
37
+ return content . writeFile ( ) . then ( _ => {
38
+ callback ( null , source , map ) ;
39
+ } ) ;
40
+ } )
41
+ . catch ( callback ) ;
34
42
} ;
0 commit comments