Skip to content
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

Fix: make file reloading handle file name changes #236

Merged
merged 1 commit into from
Mar 2, 2022

Conversation

ChristofferKarlsson
Copy link
Contributor

@ChristofferKarlsson ChristofferKarlsson commented Feb 27, 2022

Since version 1.5.0, file reloads have not worked correctly if your files are being renamed, such as when using TailwindCSS 3 (or 2 with JIT). The reason for this seems to be a bug in chokidar, that doesn't correctly handle deleting and re-creating a folder that is being directly watched. I've opened two issues in their repo about it: Issue #1207 and Issue #1208.

Before version 1.5.0 this worked, because the entire elderConfig.$$internal.distElder folder was being watched. When a folder was removed (which it seems to be in server restarts) and re-created, chokidar noticed it without problems. But in version 1.5.0, the assets and svelte folders are explicitly being watched, and not their parent directory. Due to the bugs above, they are thus no longer tracked after the first server restart that deletes the folders. See v1.5.0 changes here.

I found a workaround (see comment here) and it seems that it works if you add a trailing slash to the watches. And that is what I have changed in this PR.

For a working example, I forked the template and added TailwindCSS 3, and changed to this fixed version. It handles the CSS renaming and reloads as it should. The repo is found here: https://github.com/ChristofferKarlsson/elderjs-template-tailwind.

I have only tested this on my machine:

  • OS: Arch Linux (5.16.3-arch1-1)
  • Node version: v17.3.0

@ChristofferKarlsson ChristofferKarlsson changed the title Fix: Workaround for bug in chokidar to allow watching re-created folders Fix: make file reloading handle file name changes Feb 27, 2022
@codecov-commenter
Copy link

codecov-commenter commented Mar 1, 2022

Codecov Report

Merging #236 (0fa6c33) into master (bf528f1) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #236   +/-   ##
=======================================
  Coverage   82.14%   82.14%           
=======================================
  Files          46       46           
  Lines        1960     1960           
  Branches      465      440   -25     
=======================================
  Hits         1610     1610           
  Misses        348      348           
  Partials        2        2           
Impacted Files Coverage Δ
src/rollup/rollupPlugin.ts 76.13% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bf528f1...0fa6c33. Read the comment docs.

@nickreese nickreese merged commit 28b5f78 into Elderjs:master Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants