Repository navigation
perf: Reduce hypersensitive onChange of watcher - #978
Conversation
✅ Deploy Preview for creative-fairy-df92c4 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
| "@types/chrome": "^0.0.269", | ||
| "@aklinker1/rollup-plugin-visualizer": "5.12.0", | ||
| "@types/chrome": "^0.0.269", |
There was a problem hiding this comment.
auto sorted by pnpm.
| const reloadOnChange = debounce(createFileReloader(server), 3e2, { | ||
| leading: true, | ||
| }); |
There was a problem hiding this comment.
I'm expecting unrealistic and excessive changes by machine. Not sure if the wait-time should be shorter or longer.... 🤔
There was a problem hiding this comment.
300ms still causes the double reloads issue, I have to bump it to at least 3s
There was a problem hiding this comment.
@pnd280 I turned off trailing, so 300ms might have been OK. Please check. If it's still NG, please send us a captured video of your screen.
NOTE: perfect-debounce behaviorDetails
|
1natsu172
left a comment
There was a problem hiding this comment.
@aklinker1 I implemented env variable loading and set the default value to a tentative 800ms (based on their logs). Please review when you have time!
| // See https://github.com/wxt-dev/wxt/issues/873#issuecomment-2254555523 | ||
| process.env.NODE_ENV ??= command === 'serve' ? 'development' : 'production'; | ||
|
|
||
| loadDotenv({ path: ['.env.wxt', '.env'], quiet: true }); |
There was a problem hiding this comment.
Is this the right place to load? More top level? (cli.mjs?)
| /** | ||
| * WatchDebounce passed in from `.env.wxt` via the `WXT_WATCH_DEBOUNCE`. Which can suppress cases where dev server reloads are oversensitive. | ||
| */ | ||
| watchDebounce: number; |
There was a problem hiding this comment.
Is this the right place to set in? Or should separate to another type and config property?
@wxt-dev/auto-icons
@wxt-dev/module-react
@wxt-dev/i18n
@wxt-dev/module-solid
@wxt-dev/module-svelte
@wxt-dev/module-vue
wxt
commit: |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #978 +/- ##
==========================================
+ Coverage 81.73% 82.13% +0.39%
==========================================
Files 125 127 +2
Lines 6604 6622 +18
Branches 1098 1104 +6
==========================================
+ Hits 5398 5439 +41
+ Misses 1192 1169 -23
Partials 14 14 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
@1natsu172 sorry for the slow review on this! I made a couple of changes:
- Move config from
ConfigEnvtoResolvedConfigbecause environment variables isn't what the "env" is referencing in "ConfigEnv". That object is more for storing information about the current build setup than storing all environment variables - Updated .env loading behavior to match Vite's. See https://github.com/wxt-dev/wxt/blob/ef30d9aac1e7353a96ecf30c53df39b74a707516/packages/wxt/src/core/utils/env.ts
- Moved loading of environment variables into
resolveConfigso it refreshes the environment variables on save - Replaced
@dotenvx/dotenvxwithdotenvsince we don't need the CLI, just the env loading behavior.
Otherwise it looks good! Thanks for fielding this one!
|
@aklinker1 Oh you've already made a lot of changes and adjustments. Thanks! |
|
@1natsu172 want me to revert any of that? I figured since it took me a while to review, I'd make the changes myself to spend things up |
|
@aklinker1 No, it's okay! I was concerned about the type of env file, timing of loading, etc., but everything is clear now 👍 |
[PR wxt-dev#978](wxt-dev#978), released in [v0.19.10](https://github.com/wxt-dev/wxt/releases/tag/wxt-v0.19.10), broke variable expansion in dotenv files, a Vite built-in feature. I encountered this while migrating from v0.18.2 to the latest. Since already defined variables in process.env take presedence, the call to dotenv-expand by vite won't have any effect. Calling dotenv-expand ourselves to mimic what vite does restores the lost functionality. Vite has a slightly more complex env loading logic, so these changes won't bring 100% parity, but should be good for most use-cases. See: https://github.com/vitejs/vite/blob/642d528b7b403eb91c67ff809ffa0fb99a1ff56e/packages/vite/src/node/env.ts
[PR wxt-dev#978](wxt-dev#978), released in [v0.19.10](https://github.com/wxt-dev/wxt/releases/tag/wxt-v0.19.10), broke variable expansion in dotenv files, a Vite built-in feature. I encountered this while migrating from v0.18.2 to the latest. Since already defined variables in process.env take presedence, the call to dotenv-expand by vite won't have any effect. Calling dotenv-expand ourselves to mimic what vite does restores the lost functionality. Vite has a slightly more complex env loading logic, so these changes won't bring 100% parity, but should be good for most use-cases. See: https://github.com/vitejs/vite/blob/642d528b7b403eb91c67ff809ffa0fb99a1ff56e/packages/vite/src/node/env.ts




refer #938
Debounce the watcher's onChange.