Skip to content

Commit 1444569

Browse files
committed
Define ReactCompilerPlugin
1 parent e785706 commit 1444569

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { Compiler } from 'webpack';
2+
import { getReactCompilerLogger } from '../../loaders/reactCompilerLoader';
3+
4+
export class ReactCompilerPlugin {
5+
apply(compiler: Compiler): void {
6+
compiler.hooks.afterEmit.tap(ReactCompilerPlugin.name, () => {
7+
const logger = getReactCompilerLogger();
8+
logger.logSummary();
9+
});
10+
}
11+
}

development/webpack/webpack.config.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ import { transformManifest } from './utils/plugins/ManifestPlugin/helpers';
3434
import { parseArgv, getDryRunMessage } from './utils/cli';
3535
import { getCodeFenceLoader } from './utils/loaders/codeFenceLoader';
3636
import { getSwcLoader } from './utils/loaders/swcLoader';
37-
import {
38-
getReactCompilerLoader,
39-
getReactCompilerLogger,
40-
} from './utils/loaders/reactCompilerLoader';
37+
import { getReactCompilerLoader } from './utils/loaders/reactCompilerLoader';
4138
import { getVariables } from './utils/config';
4239
import { ManifestPlugin } from './utils/plugins/ManifestPlugin';
4340
import { getLatestCommit } from './utils/git';
@@ -216,16 +213,11 @@ if (args.progress) {
216213
const { ProgressPlugin } = require('webpack');
217214
plugins.push(new ProgressPlugin());
218215
}
219-
220216
if (args.reactCompilerVerbose) {
221-
plugins.push({
222-
apply(compiler) {
223-
compiler.hooks.done.tap('ReactCompilerStatsPlugin', () => {
224-
const logger = getReactCompilerLogger();
225-
logger.logSummary();
226-
});
227-
},
228-
} as WebpackPluginInstance);
217+
const {
218+
ReactCompilerPlugin,
219+
} = require('./utils/plugins/ReactCompilerPlugin');
220+
plugins.push(new ReactCompilerPlugin());
229221
}
230222

231223
// #endregion plugins

0 commit comments

Comments
 (0)