Conversation
Rename the third callback argument to projectRootPath and append a real OS absolutePath. Existing 3-arg plugins stay compatible. Isolate per-plugin watcher errors so one throw cannot skip the rest.
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
onFileSystemChangenow exposes a real OS absolute path without breaking existing plugins.The third argument was named
absolutePath/ used asabs, but it was the path from the project root (cwd). That mismatch made ignore checks, HMR path mapping, andstartsWith("src/")filters easy to get wrong — especially whenfileSystemWatchDirwas absolute vs relative.New callback shape
filePathprojectRootPathprocess.cwd(), posix-separated (was the 3rd arg)absolutePathpath.resolve(...)OS absolute pathBackward compatible: extra trailing argument. Existing 3-arg plugins still typecheck and still receive the project-root path in position 3.
DX / fail-safes
resolveFileChangePaths()never throws: skips null/empty/"."/".."filenames; posix-normalizesprojectRootPathsostartsWith("src/")works on Windows; files outside cwd become../…instead of crashing.join(file, filename)into a bogus nested path.dispatchFileChangeCallbacks()usesPromise.allSettledso one plugin throw (sync or async) cannot skip later plugins or leave an unhandled rejection.Plugin DX
Plugin authors can keep 3-arg handlers:
or opt into the OS path when they need
Bun.file,existsSync, or apply-react-styleresolve(cwd, path)without guessing:Docs, README, debug
watcher-changemessages, and the docs-app dev plugin were updated to the new names.Tests
test/watch-paths.test.ts— relative/.//trailing slash, absolute inside/outside cwd, posix separators,[id].tsx/spaces/unicode, skip invalid filenames, 3-arg assignability, file-watch fallbacktest/watch-dispatch.test.ts— 4-arg delivery, 3-arg BC, sync throw and async reject isolationtest/watch.test.ts— nested file args, 3-arg live callback, throw-then-continue, ignore, debounce,stop()bun test301 pass;bun run typecheckpass.Out of scope
frame-master-plugin-apply-reactstill works (resolve(cwd, 3rd)). It can switch to the 4th arg in a follow-up.