-
Notifications
You must be signed in to change notification settings - Fork 24
build: Ship components optimized with React Compiler #992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
a269639
b7a18b3
18c8f1d
0743825
7e158cf
74279f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,4 @@ docs/ | |
| /styles/ | ||
| coverage/ | ||
| .vscode/ | ||
| stats.html | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -11,5 +11,70 @@ module.exports = { | |||||
| '@babel/preset-react', | ||||||
| '@babel/preset-typescript', | ||||||
| ], | ||||||
| plugins: ['@babel/proposal-object-rest-spread'], | ||||||
| plugins: [ | ||||||
| [ | ||||||
| 'babel-plugin-react-compiler', | ||||||
| { | ||||||
| // Support React 17 as a minimum | ||||||
| target: '17', | ||||||
| logger: { | ||||||
| /** | ||||||
| * @param {string | null} filename | ||||||
| * @param {import('babel-plugin-react-compiler').LoggerEvent} event | ||||||
| */ | ||||||
| logEvent(filename, event) { | ||||||
| if ( | ||||||
| event.kind === 'CompileError' || | ||||||
| event.kind === 'CompileSkip' || | ||||||
| event.kind === 'PipelineError' | ||||||
| ) { | ||||||
| if (event.kind === 'CompileError') { | ||||||
| console.warn( | ||||||
| `\n[React Compiler] \x1b[33mCompilation skipped\x1b[0m: ${filename}`, | ||||||
| ) | ||||||
| } | ||||||
|
|
||||||
| if (event.detail?.reason) { | ||||||
| console.error(`Reason: ${event.detail.reason}`) | ||||||
| } | ||||||
|
|
||||||
| if (event.detail?.description) { | ||||||
| console.error(`Details: ${event.detail.description}`) | ||||||
| } | ||||||
|
|
||||||
| if (event.detail.primaryLocation) { | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P1] Potential Runtime Error: The
Suggested change
|
||||||
| const sourceLocation = event.detail.primaryLocation() | ||||||
|
|
||||||
| if (sourceLocation?.start) { | ||||||
| console.error( | ||||||
| `Location: Line ${sourceLocation.start.line}, Column ${sourceLocation.start.column}`, | ||||||
| ) | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| if (event.detail?.suggestions?.length) { | ||||||
| console.error('Suggestions:') | ||||||
| for (const suggestion of event.detail.suggestions) { | ||||||
| console.error(`• ${suggestion.description}`) | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| if (event.data) { | ||||||
| console.error(`Data: ${event.data}`) | ||||||
| } | ||||||
| } | ||||||
| }, | ||||||
| }, | ||||||
| }, | ||||||
| ], | ||||||
| '@babel/proposal-object-rest-spread', | ||||||
| [ | ||||||
| '@babel/plugin-transform-runtime', | ||||||
| { | ||||||
| // Prevent helpers from being inlined in the output code | ||||||
| // https://babeljs.io/docs/babel-plugin-transform-runtime#version | ||||||
| version: '^7.28.4', | ||||||
| }, | ||||||
| ], | ||||||
| ], | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Inconsistent Log Header: The current logging logic only prints a contextual header with the filename for
CompileErrorevents. ForCompileSkipandPipelineErrorevents, this header is omitted, which makes it difficult to determine which file the logged details refer to. To improve debuggability, a header should be logged for all handled event types.