-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
fix(kit,nuxt,schema,vite): improve watching behaviour #30620
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
|
@nuxt/kit
@nuxt/rspack-builder
nuxt
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
Oh, nice catch! The changes LGTM |
checked on windows, and it seems this removes the need for (it didn't make much difference vs |
WalkthroughThe pull request introduces a new function The primary modification involves updating the The implementation affects several core Nuxt processes, including build watchers, import regeneration, and Vite configuration, providing a more consistent and flexible approach to determining which files should be excluded from various operations. 📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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: 0
🧹 Nitpick comments (2)
packages/kit/src/ignore.ts (1)
13-13
: Consider documenting the unused _stats parameter.The _stats parameter is currently unused but might be intended for future use. Adding a comment explaining its purpose would improve code clarity.
packages/nuxt/src/core/builder.ts (1)
141-141
: Consider extracting the node_modules regex pattern.Since the regex pattern
/[\\/]node_modules[\\/]/
is used in multiple places, consider extracting it into a constant to maintain DRY principles and ensure consistency.+const NODE_MODULES_RE = /[\\/]node_modules[\\/]/ + function createGranularWatcher () { // ... - const watcher = chokidarWatch(dir, { ...nuxt.options.watchers.chokidar, ignoreInitial: false, depth: 0, ignored: [isIgnored, /[\\/]node_modules[\\/]/] }) + const watcher = chokidarWatch(dir, { ...nuxt.options.watchers.chokidar, ignoreInitial: false, depth: 0, ignored: [isIgnored, NODE_MODULES_RE] })
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
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 (10)
packages/kit/src/ignore.ts
(1 hunks)packages/kit/src/index.ts
(1 hunks)packages/nuxt/src/components/plugins/transform.ts
(1 hunks)packages/nuxt/src/core/builder.ts
(4 hunks)packages/nuxt/src/core/cache.ts
(2 hunks)packages/nuxt/src/core/schema.ts
(2 hunks)packages/nuxt/src/imports/module.ts
(2 hunks)packages/schema/build.config.ts
(1 hunks)packages/schema/src/config/common.ts
(1 hunks)packages/vite/src/vite.ts
(4 hunks)
🔇 Additional comments (12)
packages/schema/build.config.ts (1)
31-31
: LGTM! Addition of chokidar as an external dependency.The addition aligns with the PR's objective of improving watching behaviour.
packages/kit/src/index.ts (1)
22-22
: LGTM! Export of new createIsIgnored function.The export is properly grouped with related ignore functions and maintains alphabetical ordering.
packages/kit/src/ignore.ts (1)
6-8
: LGTM! Well-designed factory function for creating bound ignore checkers.The implementation follows the factory pattern, allowing for efficient reuse of the nuxt context.
packages/nuxt/src/components/plugins/transform.ts (1)
61-61
: LGTM! Proper usage of modified isIgnored function.The change correctly adapts to the new isIgnored signature by explicitly passing the nuxt instance.
packages/nuxt/src/core/schema.ts (1)
74-77
: Improved watcher configuration with proper context and patternsThe watcher configuration has been enhanced to:
- Use context-aware ignore patterns via
createIsIgnored(nuxt)
- Properly ignore node_modules directory
- Preserve existing chokidar options
packages/nuxt/src/imports/module.ts (1)
121-121
: Enhanced import scanning with context-aware ignore patternsThe change improves the accuracy of import scanning by using
createIsIgnored(nuxt)
, ensuring consistent ignore patterns across the application.packages/nuxt/src/core/cache.ts (1)
122-122
: Improved cache handling with context-aware ignore patternsThe change enhances cache handling by using
createIsIgnored(nuxt)
, ensuring consistent file filtering across the application.packages/vite/src/vite.ts (1)
56-56
: Enhanced Vite watcher configuration with proper context and patternsThe changes improve Vite integration by:
- Using context-aware ignore patterns via
createIsIgnored(nuxt)
- Properly configuring both build and server watchers
- Maintaining consistency with Nuxt's watcher configuration
- Preserving existing chokidar options
Also applies to: 92-92, 106-106
packages/schema/src/config/common.ts (1)
522-526
: Excellent enhancement to watcher configuration!The changes improve the robustness of file watching in two ways:
- Added type annotation ensures proper TypeScript validation of chokidar options
- Setting
ignorePermissionErrors: true
by default prevents watcher failures when encountering permission-related issues, which is particularly helpful in environments with complex file permissionspackages/nuxt/src/core/builder.ts (3)
4-4
: LGTM: Import statement updated correctly.The addition of
createIsIgnored
import aligns with the new approach to handling ignored paths.
103-103
: Improved file watching configuration increateWatcher
.The changes enhance the file watching configuration by:
- Using
createIsIgnored
for dynamic path ignoring- Replacing glob pattern with regex
/[\\/]node_modules[\\/]/
for better cross-platform compatibilityAlso applies to: 108-108
122-122
: Consistent implementation increateGranularWatcher
.The same improvements have been correctly applied to the granular watcher:
- Using
createIsIgnored
for dynamic path ignoring- Using the same regex pattern for node_modules
- Maintaining consistency with the main watcher implementation
Also applies to: 141-141
🔗 Linked issue
vitejs/vite#8619, resolves #30459, resolves #30023
📚 Description
this bundles a range of fixes to watchers in Nuxt:
createIsIgnored
function that binds a Nuxt instance to anisIgnored
handler - otherwise when restarting Nuxt, we could sometimes end up watching more files than expectedwatchers.chokidar
ignorePermissionErrors
to true by defaultwatchers.chokidar
to vite's two watcher configs (server.watch
andbuild.watch
)🚧 TODO