-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Restart dev server on package.json changes #5412
Conversation
🦋 Changeset detectedLatest commit: 4ceb81a The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
3c1f5ba
to
4ceb81a
Compare
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.
LGTM! One comment about being a bit more defensive.
if(cwd) { | ||
watchFiles.push(fileURLToPath(new URL('./package.json', pathToFileURL(cwd)))); | ||
} |
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.
This seems like an odd edge case, but should we check if package.json
exists first?
Since Deno is landing npm:
support, I think we're not far off from an Astro project that doesn't have a package.json
file being a feasible thing.
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 don't need to check for that. This is used that when a file does change and it matches one of the files in watchFiles
, it will trigger a restart. If the file doesn't exist then it will never match. It doesn't cause some other process to try and read the (potentially not existing) files.
Here's the only place this information is used:
astro/packages/astro/src/core/dev/restart.ts
Lines 55 to 57 in 7191ed1
shouldRestart = settings.watchFiles.some( | |
(path) => vite.normalizePath(path) === vite.normalizePath(changedFile) | |
); |
Changes
sass
to work when installed after the dev server has already been started.Testing
Docs
N/A, bug fix