@@ -341,4 +341,168 @@ describe('source-map-loader', () => {
341
341
expect ( bundle . indexOf ( fixture ) !== - 1 ) . toBe ( true ) ;
342
342
} ) ;
343
343
} ) ;
344
+
345
+ it . skip ( 'should process protocol-relative-url-path' , async ( ) => {
346
+ const testId = 'protocol-relative-url-path.js' ;
347
+ const compiler = getCompiler ( testId ) ;
348
+ const stats = await compile ( compiler ) ;
349
+ const codeFromBundle = getCodeFromBundle ( stats , compiler ) ;
350
+
351
+ expect ( codeFromBundle . map ) . toBeUndefined ( ) ;
352
+ expect ( codeFromBundle . css ) . toMatchSnapshot ( 'css' ) ;
353
+ expect ( getWarnings ( stats ) ) . toMatchSnapshot ( 'warnings' ) ;
354
+ expect ( getErrors ( stats ) ) . toMatchSnapshot ( 'errors' ) ;
355
+ } ) ;
356
+
357
+ it . skip ( 'should support mixed paths in sources without sourceRoot' , async ( ) => {
358
+ const sourceRoot = path . resolve ( __dirname , 'fixtures' ) ;
359
+ const javaScriptFilename = 'absolute-path.js' ;
360
+ const entryFileAbsolutePath = path . join ( sourceRoot , javaScriptFilename ) ;
361
+ const sourceMapPath = path . join ( sourceRoot , 'map-with-sourceroot.js.map' ) ;
362
+
363
+ // Create the sourcemap file
364
+ const rawSourceMap = {
365
+ version : 3 ,
366
+ sources : [
367
+ 'normal-file.js' ,
368
+ path . resolve ( __dirname , 'fixtures' , 'normal-file2.js' ) ,
369
+ 'http://path-to-map.com' ,
370
+ 'ftp://path-to-map.com' ,
371
+ ] ,
372
+ mappings : 'CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOA' ,
373
+ } ;
374
+ fs . writeFileSync ( sourceMapPath , JSON . stringify ( rawSourceMap ) ) ;
375
+
376
+ // Create the entryPointFile file
377
+ const entryFileContent = `// Some content \r\n // # sourceMappingURL=${ sourceMapPath } ` ;
378
+ fs . writeFileSync ( entryFileAbsolutePath , entryFileContent ) ;
379
+
380
+ const compiler = getCompiler ( javaScriptFilename ) ;
381
+ const stats = await compile ( compiler ) ;
382
+ const codeFromBundle = getCodeFromBundle ( stats , compiler ) ;
383
+
384
+ expect ( codeFromBundle . map ) . toBeDefined ( ) ;
385
+ expect ( normalizeMap ( codeFromBundle . map ) ) . toMatchSnapshot ( 'map' ) ;
386
+ expect ( codeFromBundle . css ) . toMatchSnapshot ( 'css' ) ;
387
+ expect ( getWarnings ( stats ) ) . toMatchSnapshot ( 'warnings' ) ;
388
+ expect ( getErrors ( stats ) ) . toMatchSnapshot ( 'errors' ) ;
389
+ } ) ;
390
+
391
+ it . skip ( 'should support mixed paths in sources with sourceRoot' , async ( ) => {
392
+ const sourceRoot = path . resolve ( __dirname , 'fixtures' ) ;
393
+ const javaScriptFilename = 'absolute-path.js' ;
394
+ const entryFileAbsolutePath = path . join ( sourceRoot , javaScriptFilename ) ;
395
+ const sourceMapPath = path . join ( sourceRoot , 'map-with-sourceroot.js.map' ) ;
396
+
397
+ // Create the sourcemap file
398
+ const rawSourceMap = {
399
+ version : 3 ,
400
+ sourceRoot,
401
+ sources : [
402
+ 'normal-file.js' ,
403
+ path . resolve ( __dirname , 'fixtures' , 'normal-file2.js' ) ,
404
+ 'http://path-to-map.com' ,
405
+ 'ftp://path-to-map.com' ,
406
+ ] ,
407
+ mappings : 'CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOA' ,
408
+ } ;
409
+ fs . writeFileSync ( sourceMapPath , JSON . stringify ( rawSourceMap ) ) ;
410
+
411
+ // Create the entryPointFile file
412
+ const entryFileContent = `// Some content \r\n // # sourceMappingURL=${ sourceMapPath } ` ;
413
+ fs . writeFileSync ( entryFileAbsolutePath , entryFileContent ) ;
414
+
415
+ const compiler = getCompiler ( javaScriptFilename ) ;
416
+ const stats = await compile ( compiler ) ;
417
+ const codeFromBundle = getCodeFromBundle ( stats , compiler ) ;
418
+
419
+ expect ( codeFromBundle . map ) . toBeDefined ( ) ;
420
+ expect ( normalizeMap ( codeFromBundle . map ) ) . toMatchSnapshot ( 'map' ) ;
421
+ expect ( codeFromBundle . css ) . toMatchSnapshot ( 'css' ) ;
422
+ expect ( getWarnings ( stats ) ) . toMatchSnapshot ( 'warnings' ) ;
423
+ expect ( getErrors ( stats ) ) . toMatchSnapshot ( 'errors' ) ;
424
+ } ) ;
425
+
426
+ it . skip ( 'should support absolute paths to sourcemaps' , async ( ) => {
427
+ const sourceRoot = path . resolve ( __dirname , 'fixtures' ) ;
428
+ const javaScriptFilename = 'absolute-path.js' ;
429
+ const entryFileAbsolutePath = path . join ( sourceRoot , javaScriptFilename ) ;
430
+ const sourceMapPath = path . join ( sourceRoot , 'normal-map.js.map' ) ;
431
+
432
+ // Create the sourcemap file
433
+ const rawSourceMap = {
434
+ version : 3 ,
435
+ sourceRoot,
436
+ sources : [
437
+ 'normal-file.js' ,
438
+ path . resolve ( __dirname , 'fixtures' , 'normal-file2.js' ) ,
439
+ ] ,
440
+ mappings : 'CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOA' ,
441
+ } ;
442
+ fs . writeFileSync ( sourceMapPath , JSON . stringify ( rawSourceMap ) ) ;
443
+
444
+ // Create the entryPointFile file
445
+ const entryFileContent = `// Some content \r\n // # sourceMappingURL=${ sourceMapPath } ` ;
446
+ fs . writeFileSync ( entryFileAbsolutePath , entryFileContent ) ;
447
+
448
+ const compiler = getCompiler ( javaScriptFilename ) ;
449
+ const stats = await compile ( compiler ) ;
450
+ const codeFromBundle = getCodeFromBundle ( stats , compiler ) ;
451
+
452
+ expect ( codeFromBundle . map ) . toBeDefined ( ) ;
453
+ expect ( normalizeMap ( codeFromBundle . map ) ) . toMatchSnapshot ( 'map' ) ;
454
+ expect ( codeFromBundle . css ) . toMatchSnapshot ( 'css' ) ;
455
+ expect ( getWarnings ( stats ) ) . toMatchSnapshot ( 'warnings' ) ;
456
+ expect ( getErrors ( stats ) ) . toMatchSnapshot ( 'errors' ) ;
457
+ } ) ;
458
+
459
+ it . skip ( 'should reject not support url' , async ( ) => {
460
+ const testId = 'unSupport-file-source-map.js' ;
461
+ const compiler = getCompiler ( testId ) ;
462
+ const stats = await compile ( compiler ) ;
463
+ const codeFromBundle = getCodeFromBundle ( stats , compiler ) ;
464
+
465
+ expect ( codeFromBundle . css ) . toMatchSnapshot ( 'css' ) ;
466
+ expect ( getWarnings ( stats ) ) . toMatchSnapshot ( 'warnings' ) ;
467
+ expect ( getErrors ( stats ) ) . toMatchSnapshot ( 'errors' ) ;
468
+ } ) ;
469
+
470
+ it . skip ( 'should process inlined sources' , async ( ) => {
471
+ const testId = 'inline-sources.js' ;
472
+ const compiler = getCompiler ( testId ) ;
473
+ const stats = await compile ( compiler ) ;
474
+ const codeFromBundle = getCodeFromBundle ( stats , compiler ) ;
475
+
476
+ expect ( codeFromBundle . map ) . toBeDefined ( ) ;
477
+ expect ( normalizeMap ( codeFromBundle . map ) ) . toMatchSnapshot ( 'map' ) ;
478
+ expect ( codeFromBundle . css ) . toMatchSnapshot ( 'css' ) ;
479
+ expect ( getWarnings ( stats ) ) . toMatchSnapshot ( 'warnings' ) ;
480
+ expect ( getErrors ( stats ) ) . toMatchSnapshot ( 'errors' ) ;
481
+ } ) ;
482
+
483
+ it . skip ( 'should process css sourceMap' , async ( ) => {
484
+ const testId = 'app.css' ;
485
+ const compiler = getCompiler ( testId ) ;
486
+ const stats = await compile ( compiler ) ;
487
+ const codeFromBundle = getCodeFromBundle ( stats , compiler ) ;
488
+
489
+ expect ( codeFromBundle . map ) . toBeDefined ( ) ;
490
+ expect ( normalizeMap ( codeFromBundle . map ) ) . toMatchSnapshot ( 'map' ) ;
491
+ expect ( codeFromBundle . css ) . toMatchSnapshot ( 'css' ) ;
492
+ expect ( getWarnings ( stats ) ) . toMatchSnapshot ( 'warnings' ) ;
493
+ expect ( getErrors ( stats ) ) . toMatchSnapshot ( 'errors' ) ;
494
+ } ) ;
495
+
496
+ it . skip ( 'should process css sourceMap' , async ( ) => {
497
+ const testId = 'skip-sourcesContent.js' ;
498
+ const compiler = getCompiler ( testId ) ;
499
+ const stats = await compile ( compiler ) ;
500
+ const codeFromBundle = getCodeFromBundle ( stats , compiler ) ;
501
+
502
+ expect ( codeFromBundle . map ) . toBeDefined ( ) ;
503
+ expect ( normalizeMap ( codeFromBundle . map ) ) . toMatchSnapshot ( 'map' ) ;
504
+ expect ( codeFromBundle . css ) . toMatchSnapshot ( 'css' ) ;
505
+ expect ( getWarnings ( stats ) ) . toMatchSnapshot ( 'warnings' ) ;
506
+ expect ( getErrors ( stats ) ) . toMatchSnapshot ( 'errors' ) ;
507
+ } ) ;
344
508
} ) ;
0 commit comments