Skip to content

Commit 3b1b9fd

Browse files
committed
refactor: type the terser-webpack-plugin module inside the minify wrapper
Annotate the required module as the plugin's default export so the wrapper and its getMinimizerVersion forward no longer return any.
1 parent f2caf84 commit 3b1b9fd

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

packages/repack/src/commands/common/config/getMinimizerConfig.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ function repackTerserMinify(
2626
minimizerOptions: TerserMinifyArgs[2],
2727
extractComments: TerserMinifyArgs[3]
2828
) {
29-
return require('terser-webpack-plugin').terserMinify(
29+
const plugin: typeof TerserPlugin = require('terser-webpack-plugin');
30+
return plugin.terserMinify(
3031
input,
3132
sourceMap,
3233
minimizerOptions,
@@ -35,8 +36,10 @@ function repackTerserMinify(
3536
}
3637

3738
// read on the main thread only, to keep terser's version in the chunk hash
38-
repackTerserMinify.getMinimizerVersion = () =>
39-
require('terser-webpack-plugin').terserMinify.getMinimizerVersion?.();
39+
repackTerserMinify.getMinimizerVersion = () => {
40+
const plugin: typeof TerserPlugin = require('terser-webpack-plugin');
41+
return plugin.terserMinify.getMinimizerVersion?.();
42+
};
4043

4144
async function getTerserConfig(rootDir: string) {
4245
const TerserPlugin = await getTerserPlugin(rootDir);

0 commit comments

Comments
 (0)