Skip to content

Commit 68e28d9

Browse files
committed
Set up loader, logger in webpack config
1 parent 9b0611f commit 68e28d9

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

development/webpack/utils/config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { join } from 'node:path';
22
import { readFileSync } from 'node:fs';
33
import { parse } from 'dotenv';
4-
import type { ReactCompilerLoaderOption } from 'react-compiler-webpack';
54
import { setEnvironmentVariables } from '../../build/set-environment-variables';
65
import type { Variables } from '../../lib/variables';
76
import type { BuildTypesConfig, BuildType } from '../../lib/build-type';
@@ -190,6 +189,3 @@ function loadConfigVars(
190189

191190
return definitions;
192191
}
193-
export const reactCompilerOptions = {
194-
target: '17',
195-
} as const satisfies ReactCompilerLoaderOption;

development/webpack/webpack.config.ts

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ import rtlCss from 'postcss-rtlcss';
1818
import autoprefixer from 'autoprefixer';
1919
import discardFonts from 'postcss-discard-font-face';
2020
import type ReactRefreshPluginType from '@pmmmwh/react-refresh-webpack-plugin';
21-
import {
22-
defineReactCompilerLoaderOption,
23-
reactCompilerLoader,
24-
} from 'react-compiler-webpack';
2521
import tailwindcss from 'tailwindcss';
2622
import { loadBuildTypesConfig } from '../lib/build-type';
2723
import {
@@ -38,7 +34,11 @@ import { transformManifest } from './utils/plugins/ManifestPlugin/helpers';
3834
import { parseArgv, getDryRunMessage } from './utils/cli';
3935
import { getCodeFenceLoader } from './utils/loaders/codeFenceLoader';
4036
import { getSwcLoader } from './utils/loaders/swcLoader';
41-
import { getVariables, reactCompilerOptions } from './utils/config';
37+
import {
38+
getReactCompilerLoader,
39+
getReactCompilerLogger,
40+
} from './utils/loaders/reactCompilerLoader';
41+
import { getVariables } from './utils/config';
4242
import { ManifestPlugin } from './utils/plugins/ManifestPlugin';
4343
import { getLatestCommit } from './utils/git';
4444

@@ -215,13 +215,29 @@ if (args.progress) {
215215
const { ProgressPlugin } = require('webpack');
216216
plugins.push(new ProgressPlugin());
217217
}
218+
219+
if (args.reactCompilerVerbose) {
220+
plugins.push({
221+
apply(compiler) {
222+
compiler.hooks.done.tap('ReactCompilerStatsPlugin', () => {
223+
const logger = getReactCompilerLogger();
224+
logger.logSummary();
225+
});
226+
},
227+
} as WebpackPluginInstance);
228+
}
229+
218230
// #endregion plugins
219231

220232
const swcConfig = { args, browsersListQuery, isDevelopment };
221233
const tsxLoader = getSwcLoader('typescript', true, safeVariables, swcConfig);
222234
const jsxLoader = getSwcLoader('ecmascript', true, safeVariables, swcConfig);
223235
const npmLoader = getSwcLoader('ecmascript', false, {}, swcConfig);
224236
const cjsLoader = getSwcLoader('ecmascript', false, {}, swcConfig, 'commonjs');
237+
const reactCompilerLoader = getReactCompilerLoader(
238+
'17',
239+
args.reactCompilerVerbose,
240+
);
225241

226242
const config = {
227243
entry,
@@ -327,12 +343,7 @@ const config = {
327343
{
328344
test: /(?!\.(?:test|stories|container))\.(?:m?[jt]s|[jt]sx)$/u,
329345
include: UI_DIR_RE,
330-
use: [
331-
{
332-
loader: reactCompilerLoader,
333-
options: defineReactCompilerLoaderOption(reactCompilerOptions),
334-
},
335-
],
346+
use: [reactCompilerLoader],
336347
},
337348
// own typescript, and own typescript with jsx
338349
{

0 commit comments

Comments
 (0)