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

Vite config is evaluated twice in Remix dev mode #10023

Open
kettanaito opened this issue Sep 24, 2024 · 0 comments
Open

Vite config is evaluated twice in Remix dev mode #10023

kettanaito opened this issue Sep 24, 2024 · 0 comments

Comments

@kettanaito
Copy link

kettanaito commented Sep 24, 2024

Reproduction

This is reproducible on any latest Remix project (sorry for not providing an exact repo, there is literally nothing specific to the app).

  1. Open vite.config.ts.
  2. Put a console.log(1) in the root scope of the module.
  3. Run npm run dev.
  4. See 1 being printed twice.

System Info

System info is irrelevant.

Used Package Manager

pnpm

Expected Behavior

Vite, its configuration and plugins are executed once.

Actual Behavior

Remix executes everything Vite-related twice. This makes it impossible to write proper Vite plugins as every hook in a plugin will be called twice.

Here are the two calls traced to see their stack traces:

Trace: 1
    at file://app/vite.config.ts.timestamp-1727182481040-668186ca07abb.mjs:25:9
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async loadConfigFromBundledFile (file:///app/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-DG6Lorbi.js:66633:15)
    at async loadConfigFromFile (file:///app/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-DG6Lorbi.js:66474:24)
    at async resolveConfig (file:///app/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-DG6Lorbi.js:66082:24)
    at async _createServer (file:///app/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-DG6Lorbi.js:62700:18)
    at async dev (/app/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/@remix-run/dev/dist/vite/dev.js:39:16)
    at async Object.viteDev (/app/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/@remix-run/dev/dist/cli/commands.js:220:3)
    at async Object.run (/app/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/@remix-run/dev/dist/cli/run.js:271:7)
    
Trace: 1
    at file://app/vite.config.ts.timestamp-1727182481241-1ed74236d2d8e.mjs:25:9
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async loadConfigFromBundledFile (file:///app/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-DG6Lorbi.js:66633:15)
    at async Module.loadConfigFromFile (file:///app/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-DG6Lorbi.js:66474:24)
    at async configResolved (/app/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/@remix-run/dev/dist/vite/plugin.js:727:37)
    at async Promise.all (index 1)
    at async resolveConfig (file:///app/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-DG6Lorbi.js:66346:3)
    at async _createServer (file:///app/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-DG6Lorbi.js:62700:18)
    at async dev (/app/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/@remix-run/dev/dist/vite/dev.js:39:16)
  • The process.pid is the same across the two calls.
  • The same behavior for .ts config format as well as .mjs.

The look quite identical to me. A bug, perhaps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants