@@ -117,6 +117,43 @@ describe('source-map-loader', () => {
117
117
expect ( getErrors ( stats ) ) . toMatchSnapshot ( 'errors' ) ;
118
118
} ) ;
119
119
120
+ it ( 'should support file protocol path' , async ( ) => {
121
+ const sourceRoot = path . resolve ( __dirname , 'fixtures' ) ;
122
+ const javaScriptFilename = 'file-protocol-path.js' ;
123
+ const entryFileAbsolutePath = path . join ( sourceRoot , javaScriptFilename ) ;
124
+ const sourceMapPath = path . join ( sourceRoot , 'file-protocol-path.js.map' ) ;
125
+
126
+ // Create the sourcemap file
127
+ const rawSourceMap = {
128
+ version : 3 ,
129
+ sources : [
130
+ 'normal-file.js' ,
131
+ `file://${ path
132
+ . resolve ( __dirname , 'fixtures' , 'normal-file2.js' )
133
+ . replace ( / \\ / g, '/' ) } `,
134
+ ] ,
135
+ mappings : 'CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOA' ,
136
+ } ;
137
+ fs . writeFileSync ( sourceMapPath , JSON . stringify ( rawSourceMap ) ) ;
138
+
139
+ // Create the entryPointFile file
140
+ const entryFileContent = `// Some content \r\n // # sourceMappingURL=file://${ sourceMapPath . replace (
141
+ / \\ / g,
142
+ '/'
143
+ ) } `;
144
+ fs . writeFileSync ( entryFileAbsolutePath , entryFileContent ) ;
145
+
146
+ const compiler = getCompiler ( javaScriptFilename ) ;
147
+ const stats = await compile ( compiler ) ;
148
+ const codeFromBundle = getCodeFromBundle ( stats , compiler ) ;
149
+
150
+ expect ( codeFromBundle . map ) . toBeDefined ( ) ;
151
+ expect ( normalizeMap ( codeFromBundle . map ) ) . toMatchSnapshot ( 'map' ) ;
152
+ expect ( codeFromBundle . css ) . toMatchSnapshot ( 'css' ) ;
153
+ expect ( getWarnings ( stats ) ) . toMatchSnapshot ( 'warnings' ) ;
154
+ expect ( getErrors ( stats ) ) . toMatchSnapshot ( 'errors' ) ;
155
+ } ) ;
156
+
120
157
it ( 'should use last SourceMap directive' , async ( ) => {
121
158
const testId = 'multi-source-map.js' ;
122
159
const compiler = getCompiler ( testId ) ;
@@ -319,6 +356,36 @@ describe('source-map-loader', () => {
319
356
expect ( getErrors ( stats ) ) . toMatchSnapshot ( 'errors' ) ;
320
357
} ) ;
321
358
359
+ it ( 'should support indexed sourcemaps 2' , async ( ) => {
360
+ const currentDirPath = path . join (
361
+ __dirname ,
362
+ 'fixtures' ,
363
+ 'indexed-sourcemap'
364
+ ) ;
365
+
366
+ const testId = path . join ( currentDirPath , 'file2.js' ) ;
367
+ const compiler = getCompiler ( testId ) ;
368
+ const stats = await compile ( compiler ) ;
369
+ const codeFromBundle = getCodeFromBundle ( stats , compiler ) ;
370
+ const deps = stats . compilation . fileDependencies ;
371
+
372
+ const dependencies = [
373
+ path . join ( currentDirPath , 'file2.js' ) ,
374
+ path . join ( currentDirPath , 'file2.js.map' ) ,
375
+ path . join ( currentDirPath , 'nested1.js' ) ,
376
+ path . normalize ( `/different/root/nested2.js` ) ,
377
+ ] ;
378
+
379
+ dependencies . forEach ( ( fixture ) => {
380
+ expect ( deps . has ( fixture ) ) . toBe ( true ) ;
381
+ } ) ;
382
+ expect ( codeFromBundle . map ) . toBeDefined ( ) ;
383
+ expect ( normalizeMap ( codeFromBundle . map ) ) . toMatchSnapshot ( 'map' ) ;
384
+ expect ( codeFromBundle . css ) . toMatchSnapshot ( 'css' ) ;
385
+ expect ( getWarnings ( stats ) ) . toMatchSnapshot ( 'warnings' ) ;
386
+ expect ( getErrors ( stats ) ) . toMatchSnapshot ( 'errors' ) ;
387
+ } ) ;
388
+
322
389
it ( 'should transform to webpack' , async ( ) => {
323
390
const currentDirPath = path . join (
324
391
__dirname ,
@@ -359,7 +426,10 @@ describe('source-map-loader', () => {
359
426
const sourceRoot = path . resolve ( __dirname , 'fixtures' ) ;
360
427
const javaScriptFilename = 'absolute-path.js' ;
361
428
const entryFileAbsolutePath = path . join ( sourceRoot , javaScriptFilename ) ;
362
- const sourceMapPath = path . join ( sourceRoot , 'map-with-sourceroot.js.map' ) ;
429
+ const sourceMapPath = path . join (
430
+ sourceRoot ,
431
+ 'map-without-sourceroot.js.map'
432
+ ) ;
363
433
364
434
// Create the sourcemap file
365
435
const rawSourceMap = {
0 commit comments