Skip to content

Commit 06b41bd

Browse files
committed
Create options for skipping annotations on components
1 parent c68361a commit 06b41bd

File tree

6 files changed

+41
-7
lines changed

6 files changed

+41
-7
lines changed

packages/bundler-plugin-core/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,10 @@ export function createRollupDebugIdUploadHooks(
610610
};
611611
}
612612

613-
export function createComponentNameAnnotateHooks() {
613+
export function createComponentNameAnnotateHooks(
614+
ignoredFiles?: string[],
615+
ignoredComponents?: string[]
616+
) {
614617
type ParserPlugins = NonNullable<
615618
NonNullable<Parameters<typeof transformAsync>[1]>["parserOpts"]
616619
>["plugins"];

packages/bundler-plugin-core/src/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,14 @@ export interface Options {
302302
* Whether the component name annotate plugin should be enabled or not.
303303
*/
304304
enabled?: boolean;
305+
/**
306+
* A list of strings representing local paths to files to ignore. The plugin will not perform any annotations on components in these files
307+
*/
308+
ignoredFiles?: string[];
309+
/**
310+
* A list of strings representing the names of components to ignore. The plugin will not perform any annotations on these components
311+
*/
312+
ignoredComponents?: string[];
305313
};
306314

307315
/**

packages/dev-utils/src/generate-documentation-table.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,20 @@ type IncludeEntry = {
359359
fullDescription: "Whether the component name annotate plugin should be enabled or not.",
360360
supportedBundlers: ["webpack", "vite", "rollup"],
361361
},
362+
{
363+
name: "ignoredFiles",
364+
type: "string[]",
365+
fullDescription:
366+
"A list of strings representing local paths to files to ignore. The plugin will not perform any annotations on components in these files.",
367+
supportedBundlers: ["webpack", "vite", "rollup"],
368+
},
369+
{
370+
name: "ignoredComponents",
371+
type: "string[]",
372+
fullDescription:
373+
"A list of strings representing the names of components to ignore. The plugin will not perform any annotations on these components.",
374+
supportedBundlers: ["webpack", "vite", "rollup"],
375+
},
362376
],
363377
},
364378
{

packages/rollup-plugin/src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ function rollupReleaseInjectionPlugin(injectionCode: string): UnpluginOptions {
1818
};
1919
}
2020

21-
function rollupComponentNameAnnotatePlugin(): UnpluginOptions {
21+
function rollupComponentNameAnnotatePlugin(
22+
ignoredFiles?: string[],
23+
ignoredComponents?: string[]
24+
): UnpluginOptions {
2225
return {
2326
name: "sentry-rollup-component-name-annotate-plugin",
24-
rollup: createComponentNameAnnotateHooks(),
27+
rollup: createComponentNameAnnotateHooks(ignoredFiles, ignoredComponents),
2528
};
2629
}
2730

packages/vite-plugin/src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ function viteReleaseInjectionPlugin(injectionCode: string): UnpluginOptions {
1919
};
2020
}
2121

22-
function viteComponentNameAnnotatePlugin(): UnpluginOptions {
22+
function viteComponentNameAnnotatePlugin(
23+
ignoredFiles?: string[],
24+
ignoredComponents?: string[]
25+
): UnpluginOptions {
2326
return {
2427
name: "sentry-vite-component-name-annotate-plugin",
2528
enforce: "pre" as const,
26-
vite: createComponentNameAnnotateHooks(),
29+
vite: createComponentNameAnnotateHooks(ignoredFiles, ignoredComponents),
2730
};
2831
}
2932

packages/webpack-plugin/src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,18 @@ function webpackReleaseInjectionPlugin(injectionCode: string): UnpluginOptions {
4747
};
4848
}
4949

50-
function webpackComponentNameAnnotatePlugin(): UnpluginOptions {
50+
function webpackComponentNameAnnotatePlugin(
51+
ignoredFiles?: string[],
52+
ignoredComponents?: string[]
53+
): UnpluginOptions {
5154
return {
5255
name: "sentry-webpack-component-name-annotate-plugin",
5356
enforce: "pre",
5457
// Webpack needs this hook for loader logic, so the plugin is not run on unsupported file types
5558
transformInclude(id) {
5659
return id.endsWith(".tsx") || id.endsWith(".jsx");
5760
},
58-
transform: createComponentNameAnnotateHooks().transform,
61+
transform: createComponentNameAnnotateHooks(ignoredFiles, ignoredComponents).transform,
5962
};
6063
}
6164

0 commit comments

Comments
 (0)