Skip to content

Commit d9aa833

Browse files
committed
stash
1 parent 1339d5c commit d9aa833

File tree

8 files changed

+189
-11
lines changed

8 files changed

+189
-11
lines changed

.depcheckrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ ignores:
8282
- 'path-browserify' # polyfill
8383
- 'nyc' # coverage
8484
- 'core-js-pure' # polyfills
85+
- 'react-compiler-webpack' # build tool
8586
# babel
8687
- '@babel/plugin-transform-logical-assignment-operators'
8788
- 'babel-plugin-react-compiler'

development/webpack/utils/config.ts

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
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';
45
import { setEnvironmentVariables } from '../../build/set-environment-variables';
56
import type { Variables } from '../../lib/variables';
67
import type { BuildTypesConfig, BuildType } from '../../lib/build-type';
@@ -189,3 +190,105 @@ function loadConfigVars(
189190

190191
return definitions;
191192
}
193+
194+
/**
195+
* React Compiler logger that tracks compilation statistics
196+
*/
197+
class ReactCompilerLogger {
198+
private compiledCount = 0;
199+
200+
private skippedCount = 0;
201+
202+
private errorCount = 0;
203+
204+
private compiledFiles: string[] = [];
205+
206+
private skippedFiles: string[] = [];
207+
208+
private errorFiles: string[] = [];
209+
210+
logEvent(filename: string | null, event: { kind: string; reason?: string }) {
211+
if (filename === null) {
212+
return;
213+
}
214+
switch (event.kind) {
215+
case 'CompileSuccess':
216+
this.compiledCount++;
217+
this.compiledFiles.push(filename);
218+
// console.log(`✅ Compiled: ${filename}`);
219+
break;
220+
case 'CompileSkip':
221+
this.skippedCount++;
222+
this.skippedFiles.push(filename);
223+
break;
224+
case 'CompileError':
225+
this.errorCount++;
226+
this.errorFiles.push(filename);
227+
// console.error(
228+
// `❌ React Compiler error in ${filename}: ${event.reason || 'Unknown error'}`,
229+
// );
230+
break;
231+
default:
232+
// Ignore other event types
233+
break;
234+
}
235+
}
236+
237+
getStats() {
238+
return {
239+
compiled: this.compiledCount,
240+
skipped: this.skippedCount,
241+
errors: this.errorCount,
242+
total: this.compiledCount + this.skippedCount + this.errorCount,
243+
compiledFiles: this.compiledFiles,
244+
skippedFiles: this.skippedFiles,
245+
errorFiles: this.errorFiles,
246+
};
247+
}
248+
249+
logSummary() {
250+
const stats = this.getStats();
251+
console.log('\n📊 React Compiler Statistics:');
252+
console.log(` ✅ Compiled: ${stats.compiled} files`);
253+
console.log(` ⏭️ Skipped: ${stats.skipped} files`);
254+
console.log(` ❌ Errors: ${stats.errors} files`);
255+
console.log(` 📦 Total processed: ${stats.total} files`);
256+
}
257+
}
258+
259+
// Create a singleton logger instance
260+
const reactCompilerLogger = new ReactCompilerLogger();
261+
262+
export const reactCompilerOptions = {
263+
target: '17',
264+
logger: reactCompilerLogger,
265+
sources: (filename) => {
266+
if (!filename.includes('/ui/')) {
267+
return false;
268+
}
269+
const excludePatterns = [
270+
'.test.',
271+
'.stories.',
272+
'.container.',
273+
'/ui/index.js',
274+
'/__mocks__/',
275+
'/__snapshots__/',
276+
'/constants/',
277+
'/helpers/',
278+
'/ducks/',
279+
'/selectors/',
280+
'/store/',
281+
];
282+
if (excludePatterns.some((pattern) => filename.includes(pattern))) {
283+
return false;
284+
}
285+
return true;
286+
},
287+
} as const satisfies ReactCompilerLoaderOption;
288+
289+
/**
290+
* Get the React Compiler logger instance for accessing statistics
291+
*/
292+
export function getReactCompilerLogger(): ReactCompilerLogger {
293+
return reactCompilerLogger;
294+
}

development/webpack/webpack.config.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ 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';
2125
import tailwindcss from 'tailwindcss';
2226
import { loadBuildTypesConfig } from '../lib/build-type';
2327
import {
@@ -33,7 +37,11 @@ import { transformManifest } from './utils/plugins/ManifestPlugin/helpers';
3337
import { parseArgv, getDryRunMessage } from './utils/cli';
3438
import { getCodeFenceLoader } from './utils/loaders/codeFenceLoader';
3539
import { getSwcLoader } from './utils/loaders/swcLoader';
36-
import { getVariables } from './utils/config';
40+
import {
41+
getVariables,
42+
reactCompilerOptions,
43+
getReactCompilerLogger,
44+
} from './utils/config';
3745
import { ManifestPlugin } from './utils/plugins/ManifestPlugin';
3846
import { getLatestCommit } from './utils/git';
3947

@@ -210,6 +218,17 @@ if (args.progress) {
210218
const { ProgressPlugin } = require('webpack');
211219
plugins.push(new ProgressPlugin());
212220
}
221+
222+
// React Compiler statistics logger plugin
223+
plugins.push({
224+
apply(compiler) {
225+
compiler.hooks.done.tap('ReactCompilerStatsPlugin', () => {
226+
const logger = getReactCompilerLogger();
227+
logger.logSummary();
228+
});
229+
},
230+
} as WebpackPluginInstance);
231+
213232
// #endregion plugins
214233

215234
const swcConfig = { args, browsersListQuery, isDevelopment };
@@ -319,6 +338,17 @@ const config = {
319338
dependency: 'url',
320339
type: 'asset/resource',
321340
},
341+
{
342+
test: /\.(?:js|mjs|jsx|ts|mts|tsx)$/u,
343+
include: /\/ui\//u,
344+
exclude: NODE_MODULES_RE,
345+
use: [
346+
{
347+
loader: reactCompilerLoader,
348+
options: defineReactCompilerLoaderOption(reactCompilerOptions),
349+
},
350+
],
351+
},
322352
// own typescript, and own typescript with jsx
323353
{
324354
test: /\.(?:ts|mts|tsx)$/u,

lavamoat/build-system/policy.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@
291291
"@babel/preset-env>@babel/helper-plugin-utils": true
292292
}
293293
},
294-
"@babel/preset-typescript>@babel/plugin-syntax-jsx": {
294+
"react-compiler-webpack>@babel/plugin-syntax-jsx": {
295295
"packages": {
296296
"@babel/preset-env>@babel/helper-plugin-utils": true
297297
}
@@ -584,7 +584,7 @@
584584
"@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-annotate-as-pure": true,
585585
"@babel/core>@babel/helper-module-transforms>@babel/helper-module-imports": true,
586586
"@babel/preset-env>@babel/helper-plugin-utils": true,
587-
"@babel/preset-typescript>@babel/plugin-syntax-jsx": true
587+
"react-compiler-webpack>@babel/plugin-syntax-jsx": true
588588
}
589589
},
590590
"@babel/preset-react>@babel/plugin-transform-react-pure-annotations": {
@@ -768,7 +768,7 @@
768768
"packages": {
769769
"@babel/preset-env>@babel/helper-plugin-utils": true,
770770
"@babel/preset-env>@babel/helper-validator-option": true,
771-
"@babel/preset-typescript>@babel/plugin-syntax-jsx": true,
771+
"react-compiler-webpack>@babel/plugin-syntax-jsx": true,
772772
"@babel/preset-env>@babel/plugin-transform-modules-commonjs": true,
773773
"@babel/preset-typescript>@babel/plugin-transform-typescript": true
774774
}
@@ -1559,10 +1559,12 @@
15591559
},
15601560
"globals": {
15611561
"Buffer": true,
1562+
"File": true,
15621563
"TextDecoder": true,
15631564
"URL": true,
15641565
"__DEV__": true,
15651566
"atob": true,
1567+
"btoa": true,
15661568
"compile": true,
15671569
"console": true,
15681570
"define": true,

lavamoat/webpack/mv2/policy.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4847,6 +4847,14 @@
48474847
"react": true
48484848
}
48494849
},
4850+
"react-compiler-runtime": {
4851+
"globals": {
4852+
"console.error": true
4853+
},
4854+
"packages": {
4855+
"react": true
4856+
}
4857+
},
48504858
"react-devtools-core": {
48514859
"globals": {
48524860
"CSSStyleRule": true,

lavamoat/webpack/mv3/policy.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3372,6 +3372,14 @@
33723372
"react": true
33733373
}
33743374
},
3375+
"react-compiler-runtime": {
3376+
"globals": {
3377+
"console.error": true
3378+
},
3379+
"packages": {
3380+
"react": true
3381+
}
3382+
},
33753383
"react-devtools-core": {
33763384
"globals": {
33773385
"CSSStyleRule": true,

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@
616616
"eslint-plugin-node": "^11.1.0",
617617
"eslint-plugin-prettier": "^5.5.1",
618618
"eslint-plugin-react": "^7.37.5",
619-
"eslint-plugin-react-compiler": "19.1.0-rc.2",
619+
"eslint-plugin-react-compiler": "^19.0.0-beta-af1b7da-20250417",
620620
"eslint-plugin-react-hooks": "^5.2.0",
621621
"eslint-plugin-storybook": "^0.6.15",
622622
"eslint-plugin-tailwindcss": "^3.18.0",
@@ -682,6 +682,7 @@
682682
"process": "^0.11.10",
683683
"pumpify": "^2.0.1",
684684
"randomcolor": "^0.5.4",
685+
"react-compiler-webpack": "0.2.1",
685686
"react-devtools": "^6.1.5",
686687
"react-devtools-core": "^6.1.5",
687688
"react-syntax-highlighter": "^15.5.0",

yarn.lock

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ __metadata:
834834
languageName: node
835835
linkType: hard
836836

837-
"@babel/plugin-syntax-jsx@npm:^7.22.5, @babel/plugin-syntax-jsx@npm:^7.25.9, @babel/plugin-syntax-jsx@npm:^7.7.2":
837+
"@babel/plugin-syntax-jsx@npm:^7.22.5, @babel/plugin-syntax-jsx@npm:^7.25.9, @babel/plugin-syntax-jsx@npm:^7.27.1, @babel/plugin-syntax-jsx@npm:^7.7.2":
838838
version: 7.27.1
839839
resolution: "@babel/plugin-syntax-jsx@npm:7.27.1"
840840
dependencies:
@@ -933,6 +933,17 @@ __metadata:
933933
languageName: node
934934
linkType: hard
935935

936+
"@babel/plugin-syntax-typescript@npm:^7.27.1":
937+
version: 7.27.1
938+
resolution: "@babel/plugin-syntax-typescript@npm:7.27.1"
939+
dependencies:
940+
"@babel/helper-plugin-utils": "npm:^7.27.1"
941+
peerDependencies:
942+
"@babel/core": ^7.0.0-0
943+
checksum: 10/87836f7e32af624c2914c73cd6b9803cf324e07d43f61dbb973c6a86f75df725e12540d91fac7141c14b697aa9268fd064220998daced156e96ac3062d7afb41
944+
languageName: node
945+
linkType: hard
946+
936947
"@babel/plugin-syntax-unicode-sets-regex@npm:^7.18.6":
937948
version: 7.18.6
938949
resolution: "@babel/plugin-syntax-unicode-sets-regex@npm:7.18.6"
@@ -24415,9 +24426,9 @@ __metadata:
2441524426
languageName: node
2441624427
linkType: hard
2441724428

24418-
"eslint-plugin-react-compiler@npm:19.1.0-rc.2":
24419-
version: 19.1.0-rc.2
24420-
resolution: "eslint-plugin-react-compiler@npm:19.1.0-rc.2"
24429+
"eslint-plugin-react-compiler@npm:19.0.0-beta-af1b7da-20250417":
24430+
version: 19.0.0-beta-af1b7da-20250417
24431+
resolution: "eslint-plugin-react-compiler@npm:19.0.0-beta-af1b7da-20250417"
2442124432
dependencies:
2442224433
"@babel/core": "npm:^7.24.4"
2442324434
"@babel/parser": "npm:^7.24.4"
@@ -24427,7 +24438,7 @@ __metadata:
2442724438
zod-validation-error: "npm:^3.0.3"
2442824439
peerDependencies:
2442924440
eslint: ">=7"
24430-
checksum: 10/cabdcbe884722049c11e84a13d1b2747c0612c61b23505fdf7b69dd9ee26e0f4bb86452486708fb359205ab5770b279d8dabac3a2d0c4409a176773eed7a4471
24441+
checksum: 10/199dc13cd81d4765e424661b7c268498f421bb91e6e25a6e9ba485ec5e99d7651dafd0ece7f43638237e2065043f635c1b4cf7639516d4efb6506f07b1d69346
2443124442
languageName: node
2443224443
linkType: hard
2443324444

@@ -33388,7 +33399,7 @@ __metadata:
3338833399
eslint-plugin-node: "npm:^11.1.0"
3338933400
eslint-plugin-prettier: "npm:^5.5.1"
3339033401
eslint-plugin-react: "npm:^7.37.5"
33391-
eslint-plugin-react-compiler: "npm:19.1.0-rc.2"
33402+
eslint-plugin-react-compiler: "npm:19.0.0-beta-af1b7da-20250417"
3339233403
eslint-plugin-react-hooks: "npm:^5.2.0"
3339333404
eslint-plugin-storybook: "npm:^0.6.15"
3339433405
eslint-plugin-tailwindcss: "npm:^3.18.0"
@@ -33486,6 +33497,7 @@ __metadata:
3348633497
react-beautiful-dnd: "npm:^13.1.1"
3348733498
react-chartjs-2: "npm:^5.2.0"
3348833499
react-compiler-runtime: "npm:^1.0.0"
33500+
react-compiler-webpack: "npm:0.2.1"
3348933501
react-devtools: "npm:^6.1.5"
3349033502
react-devtools-core: "npm:^6.1.5"
3349133503
react-dom: "npm:^17.0.2"
@@ -37650,6 +37662,19 @@ __metadata:
3765037662
languageName: node
3765137663
linkType: hard
3765237664

37665+
"react-compiler-webpack@npm:0.2.1":
37666+
version: 0.2.1
37667+
resolution: "react-compiler-webpack@npm:0.2.1"
37668+
dependencies:
37669+
"@babel/core": "npm:^7.28.4"
37670+
"@babel/plugin-syntax-jsx": "npm:^7.27.1"
37671+
"@babel/plugin-syntax-typescript": "npm:^7.27.1"
37672+
peerDependencies:
37673+
babel-plugin-react-compiler: "*"
37674+
checksum: 10/5571abebe68334969f3a40c6c21a4a6c3d8ba8a63c91348eac1209624e58e5b373609677244bbbd7480a094517c1b15f75d54400a91914728d74c9194d76775a
37675+
languageName: node
37676+
linkType: hard
37677+
3765337678
"react-devtools-core@npm:6.1.5, react-devtools-core@npm:^6.1.5":
3765437679
version: 6.1.5
3765537680
resolution: "react-devtools-core@npm:6.1.5"

0 commit comments

Comments
 (0)