diff --git a/.changeset/major-lizards-notice.md b/.changeset/major-lizards-notice.md new file mode 100644 index 00000000..509beff4 --- /dev/null +++ b/.changeset/major-lizards-notice.md @@ -0,0 +1,5 @@ +--- +'@tanstack/devtools-vite': patch +--- + +add ignore to inject source for granular manipulation diff --git a/docs/vite-plugin.md b/docs/vite-plugin.md index b13b017e..dcd316f3 100644 --- a/docs/vite-plugin.md +++ b/docs/vite-plugin.md @@ -165,7 +165,13 @@ export default { plugins: [ devtools({ injectSource: { - enabled: true + enabled: true, + ignore: { + // files to ignore source injection for + files: ['node_modules', /.*\.test\.(js|ts|jsx|tsx)$/], + // components to ignore source injection for + components: ['YourComponent', /.*Lazy$/], + }, } }), // ... rest of your plugins here diff --git a/packages/devtools-vite/package.json b/packages/devtools-vite/package.json index 6c491da0..8847bf4e 100644 --- a/packages/devtools-vite/package.json +++ b/packages/devtools-vite/package.json @@ -59,12 +59,14 @@ "@tanstack/devtools-client": "workspace:*", "@tanstack/devtools-event-bus": "workspace:*", "chalk": "^5.6.2", - "launch-editor": "^2.11.1" + "launch-editor": "^2.11.1", + "picomatch": "^4.0.3" }, "devDependencies": { "@types/babel__core": "^7.20.5", "@types/babel__generator": "^7.27.0", "@types/babel__traverse": "^7.28.0", + "@types/picomatch": "^4.0.2", "happy-dom": "^18.0.1" } } diff --git a/packages/devtools-vite/src/inject-source.test.ts b/packages/devtools-vite/src/inject-source.test.ts index d8c8d55c..f2a344aa 100644 --- a/packages/devtools-vite/src/inject-source.test.ts +++ b/packages/devtools-vite/src/inject-source.test.ts @@ -854,4 +854,36 @@ function test({...rest}) { ) }) }) + + describe('ignore patterns', () => { + it('should skip injection for ignored component names (string)', () => { + const output = addSourceToJsx( + ` + function test() { + return