@@ -14,7 +14,7 @@ test.cb('basic text content works correctly', (t) => {
14
14
resolveLoader : {
15
15
alias : { source : path . join ( __dirname , '../lib/index.js' ) }
16
16
} ,
17
- module : { loaders : [ { test : / \. t x t $ / , loader : 'source' } ] }
17
+ module : { rules : [ { test : / \. t x t $ / , loader : 'source' } ] }
18
18
} , ( err , res ) => {
19
19
if ( err ) { t . fail ( err ) }
20
20
t . truthy ( res . compilation . errors . length < 1 )
@@ -33,7 +33,7 @@ test.cb('raw source is added to loader context', (t) => {
33
33
resolveLoader : {
34
34
alias : { source : path . join ( __dirname , '../lib/index.js' ) }
35
35
} ,
36
- module : { loaders : [ { test : / \. t x t $ / , loader : 'source' } ] }
36
+ module : { rules : [ { test : / \. t x t $ / , loader : 'source' } ] }
37
37
} , ( err , res ) => {
38
38
if ( err ) { t . fail ( err ) }
39
39
const mod = res . compilation . modules . find ( ( m ) => {
@@ -55,7 +55,7 @@ test.cb('binary files not exported but are made availble for plugins', (t) => {
55
55
resolveLoader : {
56
56
alias : { source : path . join ( __dirname , '../lib/index.js' ) }
57
57
} ,
58
- module : { loaders : [ { test : / \. g i f $ / , loader : 'source' } ] }
58
+ module : { rules : [ { test : / \. g i f $ / , loader : 'source' } ] }
59
59
} , ( err , res ) => {
60
60
if ( err ) { t . fail ( err ) }
61
61
const src = fs . readFileSync ( outputPath , 'utf8' )
@@ -64,3 +64,31 @@ test.cb('binary files not exported but are made availble for plugins', (t) => {
64
64
t . end ( )
65
65
} )
66
66
} )
67
+
68
+ test . cb ( 'valid js source parsed by setting the _jsSource prop' , ( t ) => {
69
+ const outputPath = path . join ( fixturesPath , 'build-js.js' )
70
+ webpack ( {
71
+ context : fixturesPath ,
72
+ entry : path . join ( fixturesPath , 'javascript' ) ,
73
+ output : { path : fixturesPath , filename : 'build-js.js' } ,
74
+ resolveLoader : {
75
+ alias : {
76
+ source : path . join ( __dirname , '../lib/index.js' ) ,
77
+ rawJs : path . join ( __dirname , './fixtures/raw_js_mod.js' )
78
+ }
79
+ } ,
80
+ module : {
81
+ rules : [ {
82
+ test : / \. t x t $ / ,
83
+ use : [ { loader : 'source' } , { loader : 'rawJs' } ]
84
+ } ]
85
+ }
86
+ } , ( err , res ) => {
87
+ if ( err ) { t . fail ( err ) }
88
+ t . truthy ( res . compilation . errors . length < 1 )
89
+ const src = fs . readFileSync ( outputPath , 'utf8' )
90
+ t . regex ( src , / m o d u l e \. e x p o r t s = { l o o k : ' t h i s i s a c t u a l l y v a l i d j s ! ' } / )
91
+ fs . unlinkSync ( outputPath )
92
+ t . end ( )
93
+ } )
94
+ } )
0 commit comments