Skip to content

Commit ac04e97

Browse files
committed
chore: fix path
1 parent 58ee120 commit ac04e97

2 files changed

Lines changed: 55 additions & 58 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ vite.config.ts.timestamp-*
5858
.angular
5959
.nitro
6060
.sonda
61-
61+
*settings.local.json

packages/devtools-vite/src/plugin.ts

Lines changed: 54 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,15 @@ export const devtools = (args?: TanStackDevtoolsViteConfig): Array<Plugin> => {
126126
apply(config) {
127127
return config.mode === 'development' && injectSourceConfig.enabled
128128
},
129-
transform(code, id) {
130-
if (
131-
id.includes('node_modules') ||
132-
id.includes('?raw') ||
133-
id.includes('/dist/') ||
134-
id.includes('/build/')
135-
)
136-
return
137-
138-
return addSourceToJsx(code, id, args?.injectSource?.ignore)
129+
transform: {
130+
filter: {
131+
id: {
132+
exclude: [/node_modules/, /\?raw/, /\/dist\//, /\/build\//],
133+
},
134+
},
135+
handler(code, id) {
136+
return addSourceToJsx(code, id, args?.injectSource?.ignore)
137+
},
139138
},
140139
},
141140
{
@@ -550,43 +549,41 @@ export const devtools = (args?: TanStackDevtoolsViteConfig): Array<Plugin> => {
550549
(consolePipingConfig.enabled ?? true)
551550
)
552551
},
553-
transform(code, id) {
554-
// Inject the console pipe code into entry files
555-
if (
556-
id.includes('node_modules') ||
557-
id.includes('/dist/') ||
558-
id.includes('?') ||
559-
!id.match(/\.(tsx?|jsx?)$/)
560-
) {
561-
return
562-
}
563-
564-
// Only inject once - check if already injected
565-
if (code.includes('__tsdConsolePipe')) {
566-
return
567-
}
568-
569-
// Check if this is a root entry file (with <html> JSX or client entry points)
570-
// In SSR frameworks, this file runs on BOTH server (SSR) and client (hydration)
571-
// so our runtime check (typeof window === 'undefined') handles both environments
572-
const isRootEntry =
573-
/<html[\s>]/i.test(code) ||
574-
code.includes('StartClient') ||
575-
code.includes('hydrateRoot') ||
576-
code.includes('createRoot') ||
577-
(code.includes('solid-js/web') && code.includes('render('))
578-
579-
if (isRootEntry) {
580-
const viteServerUrl = `http://localhost:${port}`
581-
const inlineCode = generateConsolePipeCode(
582-
consolePipingLevels,
583-
viteServerUrl,
584-
)
552+
transform: {
553+
filter: {
554+
id: {
555+
include: /\.(tsx?|jsx?)$/,
556+
exclude: [/node_modules/, /\/dist\//, /\?/],
557+
},
558+
code: {
559+
exclude: /__tsdConsolePipe/, // avoid transforming files that already contain the console pipe code
560+
}
561+
},
562+
handler(code) {
563+
564+
565+
// Check if this is a root entry file (with <html> JSX or client entry points)
566+
// In SSR frameworks, this file runs on BOTH server (SSR) and client (hydration)
567+
// so our runtime check (typeof window === 'undefined') handles both environments
568+
const isRootEntry =
569+
/<html[\s>]/i.test(code) ||
570+
code.includes('StartClient') ||
571+
code.includes('hydrateRoot') ||
572+
code.includes('createRoot') ||
573+
(code.includes('solid-js/web') && code.includes('render('))
574+
575+
if (isRootEntry) {
576+
const viteServerUrl = `http://localhost:${port}`
577+
const inlineCode = generateConsolePipeCode(
578+
consolePipingLevels,
579+
viteServerUrl,
580+
)
585581

586-
return `${inlineCode}\n${code}`
587-
}
582+
return `${inlineCode}\n${code}`
583+
}
588584

589-
return undefined
585+
return undefined
586+
},
590587
},
591588
},
592589
{
@@ -595,18 +592,18 @@ export const devtools = (args?: TanStackDevtoolsViteConfig): Array<Plugin> => {
595592
apply(config) {
596593
return config.mode === 'development' && enhancedLogsConfig.enabled
597594
},
598-
transform(code, id) {
599-
// Ignore anything external
600-
if (
601-
id.includes('node_modules') ||
602-
id.includes('?raw') ||
603-
id.includes('/dist/') ||
604-
id.includes('/build/') ||
605-
!code.includes('console.')
606-
)
607-
return
608-
609-
return enhanceConsoleLog(code, id, port)
595+
transform: {
596+
filter: {
597+
id: {
598+
exclude: [/node_modules/, /\?raw/, /\/dist\//, /\/build\//],
599+
},
600+
code: {
601+
include: 'console.',
602+
},
603+
},
604+
handler(code, id) {
605+
return enhanceConsoleLog(code, id, port)
606+
},
610607
},
611608
},
612609
{

0 commit comments

Comments
 (0)