-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
refactor(nuxt,schema): use oxc for onPrehydrate
transform
#32045
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
Conversation
|
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.
Pull Request Overview
This PR refactors the onPrehydrate transformation logic to replace esbuild with oxc, streamlining code transformation in both testing and build configurations. Key changes include updating test regex callbacks, adding oxc configuration to the schema, refactoring the transform utility to use synchronous oxc calls, and updating package dependencies accordingly.
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
test/basic.test.ts | Revised selector callback parameter names and regex matching to align with the new transformation behavior |
packages/schema/src/types/schema.ts | Extended the configuration schema with a new oxc transform options field |
packages/schema/src/config/oxc.ts | Added a new configuration file for oxc using custom resolvers |
packages/schema/src/config/index.ts | Imported and spread the new oxc configuration |
packages/schema/package.json | Added dependency for oxc-transform |
packages/nuxt/src/core/utils/parse.ts | Replaced esbuild transform with a synchronous oxc transform and minify implementation |
packages/nuxt/src/core/plugins/prehydrate.ts | Updated prehydrate plugin to use the synchronous transformAndMinify with error handling |
packages/nuxt/package.json | Added dependencies for oxc-transform and oxc-minify |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)
test/basic.test.ts:734
- [nitpick] Consider using a more descriptive parameter name (e.g. 'element') in the forEach callback to improve code clarity.
* <script>document.querySelectorAll('[data-prehydrate-id*=":b3qlvSiBeH:"]').forEach(e=>{console.log(e.outerHTML)})</script>
Warning Rate limit exceeded@danielroe has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 0 minutes and 4 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (2)
WalkthroughThis change transitions the code transformation and minification process from an asynchronous model using esbuild to a synchronous model using oxc-transform and oxc-minify. The prehydrate plugin is updated to synchronously transform and minify code blocks with per-call error handling, removing the previous asynchronous promise aggregation. A new synchronous ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/nuxt/src/core/utils/parse.ts (1)
11-12
: Type utility definition for oxc optionsAdded a helpful type utility to ensure shape compatibility between provided options and expected types. The TODO comment suggests this might be reconsidered in the future, which is good for maintainability.
Consider removing the TODO comment if this type utility is actually necessary, or adding more context about why it might not be needed in the future.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
packages/nuxt/package.json
is excluded by!**/package.json
packages/schema/package.json
is excluded by!**/package.json
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
,!pnpm-lock.yaml
📒 Files selected for processing (6)
packages/nuxt/src/core/plugins/prehydrate.ts
(2 hunks)packages/nuxt/src/core/utils/parse.ts
(1 hunks)packages/schema/src/config/index.ts
(2 hunks)packages/schema/src/config/oxc.ts
(1 hunks)packages/schema/src/types/schema.ts
(1 hunks)test/basic.test.ts
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
packages/schema/src/config/oxc.ts (1)
packages/schema/src/utils/definition.ts (1)
defineResolvers
(50-52)
packages/nuxt/src/core/plugins/prehydrate.ts (1)
packages/nuxt/src/core/utils/parse.ts (1)
transformAndMinify
(14-23)
🔇 Additional comments (9)
packages/schema/src/config/index.ts (2)
9-9
: Clean import addition for oxc.This import correctly adds the oxc configuration module to be included in the schema, following the alphabetical ordering convention of the imports.
34-34
: Proper integration of oxc configuration.The oxc configuration is correctly spread into the default export, maintaining alphabetical ordering with the other configuration modules. This makes the oxc configuration available to the Nuxt application.
packages/schema/src/types/schema.ts (1)
1870-1874
: Well-structured schema addition for oxc.The oxc configuration schema is correctly added, following the same pattern as the existing esbuild configuration. The typing using
import('oxc-transform').TransformOptions
ensures proper type checking for oxc transformation options.packages/schema/src/config/oxc.ts (1)
3-34
: Appropriate configuration for oxc transformation optionsThis new configuration module adds support for oxc transformation options in Nuxt, with sensible defaults for JSX handling and target selection based on decorator support. The logic for resolving the target environment is well-structured, checking for explicit configuration before falling back to feature detection.
The configuration correctly uses the async resolver pattern to dynamically determine the ECMAScript target based on feature usage, defaulting to the most appropriate target for the application's needs.
packages/nuxt/src/core/plugins/prehydrate.ts (2)
5-5
: Updated import to use the new synchronous transformation functionCorrectly replaced the import of the async
transform
function with the synchronoustransformAndMinify
function to align with the new transformation approach.
31-41
: Improved transformation and error handling with synchronous approachThe refactoring from asynchronous to synchronous transformation improves error handling and simplifies the code flow. The try-catch pattern provides immediate feedback when transformation fails, which is more robust than the previous approach.
The string cleanup is also more focused, only removing trailing semicolons rather than potentially removing trailing whitespace.
packages/nuxt/src/core/utils/parse.ts (2)
6-7
: Updated imports for oxc-based transformationCorrectly removed esbuild dependencies and added imports for oxc-transform and oxc-minify, setting up the foundation for the new transformation approach.
14-23
: Well-implemented synchronous transformation and minification functionThe new
transformAndMinify
function effectively combines transformation and minification in a single synchronous operation, with proper merging of configuration options from the Nuxt instance. The comment about the synchronous nature being temporary due to a pending issue is informative for future maintainers.The function returns a properly merged result object containing all necessary properties from both the transformation and minification processes.
test/basic.test.ts (1)
742-743
: Correct regex updates for onPrehydrate scripts.The new patterns accurately match the transformed inline scripts—using
e
instead of the old variable and correctly detecting the template literalother
. LGTM.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
onPrehydrate
transform
@nuxt/kit
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
CodSpeed Performance ReportMerging #32045 will not alter performanceComparing Summary
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
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.
we might also be able to replace the usage of esbuild in packages/vite/src/plugins/analyze.ts
@danielroe will check! |
📚 Description
Simple refactor to replace esbuild with oxc for transforming onPrehydrate