Open
Description
Reproduction
This is reproducible on any latest Remix project (sorry for not providing an exact repo, there is literally nothing specific to the app).
- Open
vite.config.ts
. - Put a
console.log(1)
in the root scope of the module. - Run
npm run dev
. - 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?