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

Setting resolve.conditions causes Vite dev server run into infinite loop #171

Closed
guyutongxue opened this issue Jan 18, 2025 · 5 comments · Fixed by #173
Closed

Setting resolve.conditions causes Vite dev server run into infinite loop #171

guyutongxue opened this issue Jan 18, 2025 · 5 comments · Fixed by #173

Comments

@guyutongxue
Copy link

When setting vite.config.js as following:

import { defineConfig } from 'vite';
import solid from 'vite-plugin-solid';

// https://vite.dev/config/
export default defineConfig({
  resolve: {
    conditions: [], // <- Here, or any array that missed `"development|production"` condition
  },
  plugins: [solid()],
});

And following files including circular import:

// main.js
import { Bar } from './App.jsx';
export const foo = 0;


// App.jsx
import { foo } from './main.js';
export function Bar() {
  return foo;
}

Then the hot reload of dev server will make Vite run into infinite loops:

01:14:18 [vite] (client) hmr update /src/App.jsx
01:14:18 [vite] (client) hmr invalidate /src/App.jsx
01:14:18 [vite] (client) hmr update /src/App.jsx
01:14:18 [vite] (client) hmr invalidate /src/App.jsx
01:14:18 [vite] (client) hmr update /src/App.jsx
01:14:18 [vite] (client) hmr invalidate /src/App.jsx
01:14:18 [vite] (client) hmr update /src/App.jsx
01:14:18 [vite] (client) hmr invalidate /src/App.jsx
01:14:18 [vite] (client) hmr update /src/App.jsx
01:14:18 [vite] (client) hmr invalidate /src/App.jsx
# [ continuing ... ]

Reproducible playground

StackBlitz

Step to reproduce:

  1. Open above link and wait for the startup command to complete.
  2. Refresh the preview browser on the right.
  3. Edit src/main.js content and save. That's it, bug occurs.
@birkskyum
Copy link
Member

Which Vite version is this? 5 or 6

@guyutongxue
Copy link
Author

Which Vite version is this? 5 or 6

Vite 6.0.7

@birkskyum
Copy link
Member

birkskyum commented Jan 31, 2025

@guyutongxue can you check if the fix here works, with i.e. pnpm link?

steps: clone, pnpm i, pnpm build, and then from your repo pnpm link <path-to-vite-plugin-solid>.

@guyutongxue
Copy link
Author

@guyutongxue can you check if the fix here works, with i.e. pnpm link?

steps: clone, pnpm i, pnpm build, and then from your repo pnpm link <path-to-vite-plugin-solid>.

Yes, confirmed that #173 will fix my issue.

@birkskyum
Copy link
Member

I can confirm it too in this stackblitz

https://stackblitz.com/edit/vitejs-vite-1k7n1gjp?file=src%2FApp.jsx

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 a pull request may close this issue.

2 participants