@@ -44,27 +44,33 @@ export default function localizeExtractLoader(
44
44
} ,
45
45
} ;
46
46
47
+ let filename = loaderContext . resourcePath ;
48
+ if ( map ?. file ) {
49
+ // The extractor's internal sourcemap handling expects the filenames to match
50
+ filename = nodePath . posix . join ( loaderContext . context , map . file ) ;
51
+ }
52
+
47
53
// Setup a virtual file system instance for the extractor
48
54
// * MessageExtractor itself uses readFile and resolve
49
55
// * Internal SourceFileLoader (sourcemap support) uses dirname, exists, readFile, and resolve
50
56
const filesystem = {
51
57
readFile ( path : string ) : string {
52
- if ( path === loaderContext . resourcePath ) {
58
+ if ( path === filename ) {
53
59
return content ;
54
- } else if ( path === loaderContext . resourcePath + '.map' ) {
60
+ } else if ( path === filename + '.map' ) {
55
61
return typeof map === 'string' ? map : JSON . stringify ( map ) ;
56
62
} else {
57
- throw new Error ( 'Unknown file requested.' ) ;
63
+ throw new Error ( 'Unknown file requested: ' + path ) ;
58
64
}
59
65
} ,
60
66
resolve ( ...paths : string [ ] ) : string {
61
- return nodePath . resolve ( ...paths ) ;
67
+ return nodePath . posix . resolve ( ...paths ) ;
62
68
} ,
63
69
exists ( path : string ) : boolean {
64
- return path === loaderContext . resourcePath || path === loaderContext . resourcePath + '.map' ;
70
+ return path === filename || path === filename + '.map' ;
65
71
} ,
66
72
dirname ( path : string ) : string {
67
- return nodePath . dirname ( path ) ;
73
+ return nodePath . posix . dirname ( path ) ;
68
74
} ,
69
75
} ;
70
76
@@ -75,7 +81,7 @@ export default function localizeExtractLoader(
75
81
useSourceMaps : ! ! map ,
76
82
} ) ;
77
83
78
- const messages = extractor . extractMessages ( loaderContext . resourcePath ) ;
84
+ const messages = extractor . extractMessages ( filename ) ;
79
85
if ( messages . length > 0 ) {
80
86
options ?. messageHandler ( messages ) ;
81
87
}
0 commit comments