From 430e9cdbb1a42c615c62456d512d910474e1d6f0 Mon Sep 17 00:00:00 2001 From: atanasster Date: Sat, 1 May 2021 12:51:26 -0400 Subject: [PATCH] fix: callback invoke on hmr --- core/webpack-compile/src/index.ts | 4 +--- core/webpack-compile/src/utilities.ts | 6 +++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/webpack-compile/src/index.ts b/core/webpack-compile/src/index.ts index 4d6a8e772..4dd588b2a 100644 --- a/core/webpack-compile/src/index.ts +++ b/core/webpack-compile/src/index.ts @@ -48,10 +48,8 @@ export const watch = async ( ...rest, mode: 'development', }, + callback, ); - if (callback) { - await callback(results); - } return results; }; diff --git a/core/webpack-compile/src/utilities.ts b/core/webpack-compile/src/utilities.ts index b00780861..a39660bfb 100644 --- a/core/webpack-compile/src/utilities.ts +++ b/core/webpack-compile/src/utilities.ts @@ -133,12 +133,13 @@ const createConfig = (options: BuildProps): webpack.Configuration => { export const runCompiler = ( run: (compiler: Compiler, callback: Parameters[0]) => void, props: BuildProps, + callback?: CompilerCallbackFn, ): Promise => { return new Promise(resolve => { const buildConfig = mergeBuildConfiguration(props); const compiler = webpack(createConfig(buildConfig)); - run(compiler, (err, stats) => { + run(compiler, async (err, stats) => { const bundleName = path.join( stats?.compilation.outputOptions?.path || '', typeof stats?.compilation.outputOptions.filename === 'string' @@ -179,6 +180,9 @@ module.exports = ${JSON.stringify({ }`, bundleName, ); + if (callback) { + await callback({ store, stats: stats as Stats, bundleName }); + } } else { error('error creating bundle', bundleName); }