File tree 2 files changed +38
-1
lines changed
test/samples/sourceless-transform
2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ export default function buildSourceMapTree(
31
31
const map = maps . pop ( ) ! ;
32
32
33
33
for ( let i = 0 ; i < maps . length ; i ++ ) {
34
- if ( maps [ i ] . sources . length !== 1 ) {
34
+ if ( maps [ i ] . sources . length > 1 ) {
35
35
throw new Error (
36
36
`Transformation map ${ i } must have exactly one source file.\n` +
37
37
'Did you specify these with the most recent transformation maps first?'
Original file line number Diff line number Diff line change
1
+ import remapping from '../../../src/remapping' ;
2
+
3
+ describe ( 'source-less transform' , ( ) => {
4
+ const original : any = {
5
+ version : '3' ,
6
+ sources : [ 'source.ts' ] ,
7
+ names : [ ] ,
8
+ mappings : 'AAAA' ,
9
+ sourcesContent : [ '// hello' ] ,
10
+ } ;
11
+ const minified : any = {
12
+ version : '3' ,
13
+ sources : [ ] ,
14
+ names : [ ] ,
15
+ mappings : '' ,
16
+ } ;
17
+
18
+ test ( 'remapping with loader generates empty sourcemap' , ( ) => {
19
+ const loader = jest . fn ( ( ) => null ) ;
20
+ loader . mockReturnValueOnce ( original ) ;
21
+ const remapped = remapping ( minified , loader ) ;
22
+
23
+ expect ( loader ) . not . toHaveBeenCalled ( ) ;
24
+ expect ( remapped . sources ) . toHaveLength ( 0 ) ;
25
+ expect ( remapped . mappings ) . toBe ( '' ) ;
26
+ } ) ;
27
+
28
+ test ( 'remapping with array shorthand generates empty sourcemap' , ( ) => {
29
+ const loader = jest . fn ( ( ) => null ) ;
30
+ const remapped = remapping ( [ minified , original ] , loader ) ;
31
+
32
+ expect ( loader ) . toHaveBeenCalledTimes ( 1 ) ;
33
+ expect ( loader ) . toHaveBeenCalledWith ( 'source.ts' ) ;
34
+ expect ( remapped . sources ) . toHaveLength ( 0 ) ;
35
+ expect ( remapped . mappings ) . toBe ( '' ) ;
36
+ } ) ;
37
+ } ) ;
You can’t perform that action at this time.
0 commit comments