Skip to content

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

@guyutongxue

Description

@guyutongxue

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions