@@ -14,7 +14,7 @@ test.cb('basic text content works correctly', (t) => {
1414 resolveLoader : {
1515 alias : { source : path . join ( __dirname , '../lib/index.js' ) }
1616 } ,
17- module : { loaders : [ { test : / \. t x t $ / , loader : 'source' } ] }
17+ module : { rules : [ { test : / \. t x t $ / , loader : 'source' } ] }
1818 } , ( err , res ) => {
1919 if ( err ) { t . fail ( err ) }
2020 t . truthy ( res . compilation . errors . length < 1 )
@@ -33,7 +33,7 @@ test.cb('raw source is added to loader context', (t) => {
3333 resolveLoader : {
3434 alias : { source : path . join ( __dirname , '../lib/index.js' ) }
3535 } ,
36- module : { loaders : [ { test : / \. t x t $ / , loader : 'source' } ] }
36+ module : { rules : [ { test : / \. t x t $ / , loader : 'source' } ] }
3737 } , ( err , res ) => {
3838 if ( err ) { t . fail ( err ) }
3939 const mod = res . compilation . modules . find ( ( m ) => {
@@ -55,7 +55,7 @@ test.cb('binary files not exported but are made availble for plugins', (t) => {
5555 resolveLoader : {
5656 alias : { source : path . join ( __dirname , '../lib/index.js' ) }
5757 } ,
58- module : { loaders : [ { test : / \. g i f $ / , loader : 'source' } ] }
58+ module : { rules : [ { test : / \. g i f $ / , loader : 'source' } ] }
5959 } , ( err , res ) => {
6060 if ( err ) { t . fail ( err ) }
6161 const src = fs . readFileSync ( outputPath , 'utf8' )
@@ -64,3 +64,31 @@ test.cb('binary files not exported but are made availble for plugins', (t) => {
6464 t . end ( )
6565 } )
6666} )
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