File tree Expand file tree Collapse file tree 4 files changed +16
-3
lines changed
Expand file tree Collapse file tree 4 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ module . exports = class ChildCompilerPlugin {
4+ apply ( compiler ) {
5+ compiler . hooks . make . tapAsync ( 'ChildCompilerPlugin' , ( compilation , callback ) => {
6+ const childCompiler = compilation . createChildCompiler ( 'ChildCompilerPlugin' ) ;
7+ childCompiler . runAsChild ( callback ) ;
8+ } ) ;
9+ }
10+ } ;
Original file line number Diff line number Diff line change 11'use strict' ;
22const AddAssetPlugin = require ( '..' ) ;
3+ const ChildCompilerPlugin = require ( './child-compiler-plugin' ) ;
34
45module . exports = {
56 output : {
@@ -9,6 +10,7 @@ module.exports = {
910 plugins : [
1011 new AddAssetPlugin ( 'rainbow.js' , 'console.log("π")' ) ,
1112 new AddAssetPlugin ( 'cake.js' , ( ) => 'console.log("π")' ) ,
12- new AddAssetPlugin ( 'cat.js' , ( ) => Promise . resolve ( 'console.log("π")' ) )
13+ new AddAssetPlugin ( 'cat.js' , ( ) => Promise . resolve ( 'console.log("π")' ) ) ,
14+ new ChildCompilerPlugin ( )
1315 ]
1416} ;
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ module.exports = class AddAssetPlugin {
1313 }
1414
1515 apply ( compiler ) {
16- compiler . hooks . compilation . tap ( 'AddAssetPlugin' , compilation => {
16+ compiler . hooks . thisCompilation . tap ( 'AddAssetPlugin' , compilation => {
1717 compilation . hooks . processAssets . tapPromise ( tapOptions , async ( ) => {
1818 let source ;
1919 if ( typeof this . source === 'string' ) {
Original file line number Diff line number Diff line change @@ -9,7 +9,8 @@ test('main', async t => {
99 const config = require ( './fixture/webpack.config' ) ;
1010 const cwd = tempy . directory ( ) ;
1111 config . output . path = cwd ;
12- await pify ( webpack ) ( config ) ;
12+ const stats = await pify ( webpack ) ( config ) ;
13+ t . false ( stats . hasErrors ( ) ) ;
1314 t . true ( fs . readFileSync ( path . join ( cwd , 'unicorn.js' ) , 'utf8' ) . includes ( 'π¦' ) ) ;
1415 t . true ( fs . readFileSync ( path . join ( cwd , 'rainbow.js' ) , 'utf8' ) . includes ( 'π' ) ) ;
1516 t . true ( fs . readFileSync ( path . join ( cwd , 'cake.js' ) , 'utf8' ) . includes ( 'π' ) ) ;
You canβt perform that action at this time.
0 commit comments