From b5d812445ab82e5eb5f26927eacf30fd9bab9d8b Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Mon, 20 Oct 2025 16:22:33 +0200 Subject: [PATCH 1/7] fix: remove completely devtools in hosting providers --- packages/devtools-vite/src/plugin.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/devtools-vite/src/plugin.ts b/packages/devtools-vite/src/plugin.ts index 93248fef..14de2d59 100644 --- a/packages/devtools-vite/src/plugin.ts +++ b/packages/devtools-vite/src/plugin.ts @@ -178,8 +178,14 @@ export const devtools = (args?: TanStackDevtoolsViteConfig): Array => { }, { name: '@tanstack/devtools:remove-devtools-on-build', - apply(_, { command }) { - return command === 'build' && removeDevtoolsOnBuild + apply(config, { command }) { + // Check both command and mode to support various hosting providers + // Some providers (Cloudflare, Netlify, Heroku) might not use 'build' command + // but will always set mode to 'production' for production builds + return ( + (command !== 'serve' || config.mode === 'production') && + removeDevtoolsOnBuild + ) }, enforce: 'pre', transform(code, id) { From 2721a2a7bdf1b47493cdeb7451d6db6f6cb810d6 Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Mon, 20 Oct 2025 16:23:30 +0200 Subject: [PATCH 2/7] changeset --- .changeset/nine-ravens-push.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/nine-ravens-push.md diff --git a/.changeset/nine-ravens-push.md b/.changeset/nine-ravens-push.md new file mode 100644 index 00000000..9a8dd5fb --- /dev/null +++ b/.changeset/nine-ravens-push.md @@ -0,0 +1,5 @@ +--- +'@tanstack/devtools-vite': patch +--- + +fix issue where hosting providers would include devtools in production From b11a065860ea1e538a7c33605e15f8265a675ec9 Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Mon, 20 Oct 2025 16:56:06 +0200 Subject: [PATCH 3/7] add logs --- packages/devtools-vite/src/plugin.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/devtools-vite/src/plugin.ts b/packages/devtools-vite/src/plugin.ts index 14de2d59..a6a66bd3 100644 --- a/packages/devtools-vite/src/plugin.ts +++ b/packages/devtools-vite/src/plugin.ts @@ -179,6 +179,7 @@ export const devtools = (args?: TanStackDevtoolsViteConfig): Array => { { name: '@tanstack/devtools:remove-devtools-on-build', apply(config, { command }) { + console.log('remove-devtools-on-build apply called', config, command) // Check both command and mode to support various hosting providers // Some providers (Cloudflare, Netlify, Heroku) might not use 'build' command // but will always set mode to 'production' for production builds From 571bb180b783059be1088a8dc0422692050d676d Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Mon, 20 Oct 2025 17:04:47 +0200 Subject: [PATCH 4/7] log --- packages/devtools-vite/src/plugin.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/devtools-vite/src/plugin.ts b/packages/devtools-vite/src/plugin.ts index a6a66bd3..b3392d64 100644 --- a/packages/devtools-vite/src/plugin.ts +++ b/packages/devtools-vite/src/plugin.ts @@ -179,7 +179,11 @@ export const devtools = (args?: TanStackDevtoolsViteConfig): Array => { { name: '@tanstack/devtools:remove-devtools-on-build', apply(config, { command }) { - console.log('remove-devtools-on-build apply called', config, command) + console.log( + chalk.redBright('remove-devtools-on-build apply called'), + config, + command, + ) // Check both command and mode to support various hosting providers // Some providers (Cloudflare, Netlify, Heroku) might not use 'build' command // but will always set mode to 'production' for production builds From f07ff0202e9f19bf876379b983dbdd19a397a397 Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Mon, 20 Oct 2025 17:20:19 +0200 Subject: [PATCH 5/7] fix for bundling --- packages/devtools-vite/src/plugin.ts | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/packages/devtools-vite/src/plugin.ts b/packages/devtools-vite/src/plugin.ts index b3392d64..665ee83c 100644 --- a/packages/devtools-vite/src/plugin.ts +++ b/packages/devtools-vite/src/plugin.ts @@ -179,11 +179,6 @@ export const devtools = (args?: TanStackDevtoolsViteConfig): Array => { { name: '@tanstack/devtools:remove-devtools-on-build', apply(config, { command }) { - console.log( - chalk.redBright('remove-devtools-on-build apply called'), - config, - command, - ) // Check both command and mode to support various hosting providers // Some providers (Cloudflare, Netlify, Heroku) might not use 'build' command // but will always set mode to 'production' for production builds @@ -194,13 +189,7 @@ export const devtools = (args?: TanStackDevtoolsViteConfig): Array => { }, enforce: 'pre', transform(code, id) { - if ( - id.includes('node_modules') || - id.includes('?raw') || - id.includes('dist') || - id.includes('build') - ) - return + if (id.includes('node_modules') || id.includes('?raw')) return const transform = removeDevtools(code, id) if (!transform) return if (logging) { From 2dce88f6f21c86259ae2219badc94b6b48de201c Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Mon, 20 Oct 2025 17:34:28 +0200 Subject: [PATCH 6/7] fix for bundling --- packages/devtools-vite/src/plugin.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/devtools-vite/src/plugin.ts b/packages/devtools-vite/src/plugin.ts index 665ee83c..c7534309 100644 --- a/packages/devtools-vite/src/plugin.ts +++ b/packages/devtools-vite/src/plugin.ts @@ -191,6 +191,7 @@ export const devtools = (args?: TanStackDevtoolsViteConfig): Array => { transform(code, id) { if (id.includes('node_modules') || id.includes('?raw')) return const transform = removeDevtools(code, id) + console.log(chalk.greenBright('checking transform'), id, !!transform) if (!transform) return if (logging) { console.log( From df240164d21f6daae926824b2a008c7ee9ae1103 Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Mon, 20 Oct 2025 17:37:44 +0200 Subject: [PATCH 7/7] fix --- packages/devtools-vite/src/plugin.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/devtools-vite/src/plugin.ts b/packages/devtools-vite/src/plugin.ts index c7534309..665ee83c 100644 --- a/packages/devtools-vite/src/plugin.ts +++ b/packages/devtools-vite/src/plugin.ts @@ -191,7 +191,6 @@ export const devtools = (args?: TanStackDevtoolsViteConfig): Array => { transform(code, id) { if (id.includes('node_modules') || id.includes('?raw')) return const transform = removeDevtools(code, id) - console.log(chalk.greenBright('checking transform'), id, !!transform) if (!transform) return if (logging) { console.log(