diff --git a/.changeset/twenty-impalas-poke.md b/.changeset/twenty-impalas-poke.md new file mode 100644 index 00000000..9e3ec118 --- /dev/null +++ b/.changeset/twenty-impalas-poke.md @@ -0,0 +1,5 @@ +--- +'@tanstack/devtools-vite': patch +--- + +Fix console pipe feedback loop and solid-js duplication with Vite 8 diff --git a/packages/devtools-vite/src/plugin.ts b/packages/devtools-vite/src/plugin.ts index 22abc2f7..a8853dbb 100644 --- a/packages/devtools-vite/src/plugin.ts +++ b/packages/devtools-vite/src/plugin.ts @@ -146,7 +146,7 @@ export const devtools = (args?: TanStackDevtoolsViteConfig): Array => { return } - /* const solidDedupeDeps = [ + const solidDedupeDeps = [ 'solid-js', 'solid-js/web', 'solid-js/store', @@ -161,7 +161,7 @@ export const devtools = (args?: TanStackDevtoolsViteConfig): Array => { optimizeDeps: { include: solidDedupeDeps, }, - } */ + } }, }, { @@ -223,6 +223,10 @@ export const devtools = (args?: TanStackDevtoolsViteConfig): Array => { await editor.open(path, lineNum, columnNum) } + const originalConsole = Object.fromEntries( + consolePipingLevels.map((l) => [l, console[l].bind(console)]), + ) as Record + // SSE clients for broadcasting server logs to browser const sseClients: Array<{ res: ServerResponse @@ -248,7 +252,9 @@ export const devtools = (args?: TanStackDevtoolsViteConfig): Array => { onConsolePipe: (entries) => { for (const entry of entries) { const prefix = chalk.cyan('[Client]') - const logMethod = console[entry.level as ConsoleLevel] + const logMethod = + originalConsole[entry.level as ConsoleLevel] || + originalConsole.log const cleanedArgs = stripEnhancedLogPrefix( entry.args, (loc) => chalk.gray(loc),