This repository was archived by the owner on Apr 6, 2021. It is now read-only.
Bust persistent cache (webpack 5) on module load #6
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.
Edit: 2 seconds after opening this I realised there's already a PR for this 🤦
webpack 5 has a persistent cache option. This stores cache on the filesystem so that it can be reused across builds. Our current implementation has an issue with stale CSS when this option is enabled.
How to reproduce the issue in a Next.js app:
future.webpack5
totrue
innext.config.js
:.next
directory if it existsnpm run dev
ctrl + c
)npm run dev
Solution
This PR proposes a solution to this problem:
path.join(os.homedir() || os.tmpdir(), '.tailwindcss', 'touch')
Why
os.homedir()
?The home directory seems like a more stable place to put the touch files. I don't fully understand tmp directories or when and why they change. My concern would be that
os.tmpdir()
starts returning a different directory name but the previous one still exists.In terms of whether this is acceptable to do, my home directory looks like this:
I looked at the source code for
degit
and it uses thehome-or-tmp
module to pick a folder (the module is literallymodule.exports = os.homedir() || os.tmpdir()
)