fix: file reloading mechanism and add profile watch ignores#2112
fix: file reloading mechanism and add profile watch ignores#2112ZerGo0 wants to merge 12 commits intowxt-dev:mainfrom
Conversation
- Exported `createFileReloader` function to allow external usage. - Improved the file reloading process by implementing a queue worker to handle multiple file changes without dropping events. - Added `getRunnerProfileWatchIgnores` function to dynamically generate ignored paths based on user profiles for Chromium and Firefox. - Updated Vite builder configuration to include these new ignore patterns.
❌ Deploy Preview for creative-fairy-df92c4 failed.
|
aklinker1
left a comment
There was a problem hiding this comment.
Nice, I really like these changes!
I just woke up and am on mobile, so I'll need to do some manual testing to make sure everything is working later today.
@wxt-dev/analytics
@wxt-dev/auto-icons
@wxt-dev/browser
@wxt-dev/i18n
@wxt-dev/is-background
@wxt-dev/module-react
@wxt-dev/module-solid
@wxt-dev/module-svelte
@wxt-dev/module-vue
@wxt-dev/runner
@wxt-dev/storage
@wxt-dev/unocss
@wxt-dev/webextension-polyfill
wxt
commit: |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2112 +/- ##
==========================================
+ Coverage 79.73% 80.40% +0.67%
==========================================
Files 131 131
Lines 3804 3894 +90
Branches 861 883 +22
==========================================
+ Hits 3033 3131 +98
+ Misses 686 680 -6
+ Partials 85 83 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Introduced `getRelevantDevChangedFiles` to filter out unrelated file changes. - Updated `detectDevChanges` to utilize the new filtering function for improved accuracy. - Modified `createFileReloader` to work with relevant file changes, ensuring only necessary reloads occur. - Enhanced tests to validate the new behavior and ensure proper handling of HTML-only reloads.
|
I pushed another small change. I don't really like the changes in 0cf79bb but I can't really think of a better way of doing this. The problem is that it would show potentially wrong files in the "Changed: ..." log line and so on because they all use the "raw"/unfiltered queue. My latest commit fixes that. |
|
I'm also have 1 file on which HMR doesn't work and i was about to report it, but i'll check it on your branch, maybe your PR will solve that issue 😄 |
aklinker1
left a comment
There was a problem hiding this comment.
Tested, things seem to behave the same way for me. One requested change.
Move createFileReloader into an internal core utils file and update create-server/test imports.
- Exported `createFileReloader` function to allow external usage. - Improved the file reloading process by implementing a queue worker to handle multiple file changes without dropping events. - Added `getRunnerProfileWatchIgnores` function to dynamically generate ignored paths based on user profiles for Chromium and Firefox. - Updated Vite builder configuration to include these new ignore patterns.
- Introduced `getRelevantDevChangedFiles` to filter out unrelated file changes. - Updated `detectDevChanges` to utilize the new filtering function for improved accuracy. - Modified `createFileReloader` to work with relevant file changes, ensuring only necessary reloads occur. - Enhanced tests to validate the new behavior and ensure proper handling of HTML-only reloads.
Move createFileReloader into an internal core utils file and update create-server/test imports.
41b2084 to
9e4d40d
Compare
|
it's working for Windows also, but it doesn't solve my issue, i'll open new issue about it. |
…into fix/dev-watch-missed-reloads
- detect entrypoint directory file events that are missed by step-based dev change detection and treat them as rebuild candidates. - recompute and merge latest entrypoint groups on file changes so new entrypoints are built immediately instead of waiting for a dev server restart. - reload the extension when new entrypoints are introduced to keep manifest/runtime behavior in sync. - add and update `createFileReloader` tests to cover noisy events and newly added entrypoint files.
|
@aklinker1 This one also, needs your review |
| ): string[] { | ||
| const root = normalizePath(wxtConfig.root); | ||
| const chromiumArgProfiles = extractPathArgs( | ||
| wxtConfig.runnerConfig.config?.chromiumArgs, |
There was a problem hiding this comment.
Hmm, I'm working on adding an alternative runner in the next major version and hardcoding access to one of the runner's config will prevent me from abstracting it.
It works for now like this, but we'll likely have to add a hook for this in the future...
Just thinking out loud, no changes here.
| @@ -1,35 +1,15 @@ | |||
| import { debounce } from 'perfect-debounce'; | |||
There was a problem hiding this comment.
Can we remove this dependency?
|
@aklinker1 I can do a clean PR if you want? (This issue is super frustrating tbh, 1/20 file saves trigger a rebuild/reload for me right now for me. It's usually faster to just stop and start the dev command ^^) |
|
Yeah, resolve the conflicts and I'll finish reviewing it. |
…d-reloads # Conflicts: # packages/wxt/src/core/builders/vite/index.ts # packages/wxt/src/core/utils/create-file-reloader.ts
| expect(server.reloadExtension).toBeCalledTimes(1); | ||
| }); | ||
|
|
||
| it('should rebuild and reload extension when a new entrypoint is added', async () => { |
There was a problem hiding this comment.
I noticed you resolved that TODO, thanks!
| const needsFullExtensionReload = | ||
| newEntrypointGroups.length || | ||
| changes.type === 'extension-reload' || | ||
| changes.type === 'no-change'; | ||
| if (needsFullExtensionReload) { | ||
| server.reloadExtension(); | ||
| wxt.logger.success(`Reloaded extension`); |
There was a problem hiding this comment.
Alright, changes look good. This is the only thing that stood out to me: why reload the extension when no changes were detected?
There was a problem hiding this comment.
I'm pretty sure that I added it as a temp fix for new entry points, but I removed it now since it's not needed anymore.
Overview
Fixes flaky dev reload detection where WXT sometimes ignores real source file saves.
Root cause:
leading: true,trailing: false) and queued events inside that callback.Changes:
packages/wxt/src/core/create-server.tsto:packages/wxt/src/core/builders/vite/index.tsso browser profile churn is not watched:chromiumProfilefirefoxProfilechromiumArgs--user-data-dir(split and=forms)firefoxArgs-profile(split and=forms)packages/wxt/src/core/__tests__/create-server.test.tsManual Testing
This is pretty hard/annoying to reproduce. The new test is probably the best way of reproducing this:
pnpm -C packages/wxt test --run src/core/__tests__/create-server.test.tschromiumArgs: ['--user-data-dir=./private/.dev-profile']firefoxProfile: './private/.dev-firefox-profile'pnpm wxt.Related Issue
None I think.