Skip to content

Commit 213cb8c

Browse files
committed
wire up options to allow bundler plugins to skip certain files for react annotation
1 parent 911cd63 commit 213cb8c

File tree

1 file changed

+21
-7
lines changed
  • packages/bundler-plugin-core/src

1 file changed

+21
-7
lines changed

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

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ import { fileDeletionPlugin } from "./plugins/sourcemap-deletion";
2929

3030
interface SentryUnpluginFactoryOptions {
3131
releaseInjectionPlugin: (injectionCode: string) => UnpluginOptions;
32-
componentNameAnnotatePlugin?: () => UnpluginOptions;
32+
componentNameAnnotatePlugin?: (
33+
ignoredFiles?: string[],
34+
ignoredComponents?: string[]
35+
) => UnpluginOptions;
3336
moduleMetadataInjectionPlugin: (injectionCode: string) => UnpluginOptions;
3437
debugIdInjectionPlugin: (logger: Logger) => UnpluginOptions;
3538
debugIdUploadPlugin: (upload: (buildArtifacts: string[]) => Promise<void>) => UnpluginOptions;
@@ -399,7 +402,13 @@ export function sentryUnpluginFactory({
399402
"The component name annotate plugin is currently not supported by '@sentry/esbuild-plugin'"
400403
);
401404
} else {
402-
componentNameAnnotatePlugin && plugins.push(componentNameAnnotatePlugin());
405+
componentNameAnnotatePlugin &&
406+
plugins.push(
407+
componentNameAnnotatePlugin(
408+
options.reactComponentAnnotation.ignoredFiles,
409+
options.reactComponentAnnotation.ignoredComponents
410+
)
411+
);
403412
}
404413
}
405414

@@ -627,14 +636,19 @@ export function createComponentNameAnnotateHooks(
627636
return null;
628637
}
629638

630-
const isIgnoredFile = ignoredFiles?.some((file) => idWithoutQueryAndHash.endsWith(file));
631-
if (isIgnoredFile) {
632-
console.log(`FOUND IGNORED FILE: ${idWithoutQueryAndHash}`);
639+
// We will only apply this plugin on jsx and tsx files
640+
if (![".jsx", ".tsx"].some((ending) => idWithoutQueryAndHash.endsWith(ending))) {
633641
return null;
634642
}
635643

636-
// We will only apply this plugin on jsx and tsx files
637-
if (![".jsx", ".tsx"].some((ending) => idWithoutQueryAndHash.endsWith(ending))) {
644+
console.log("ignored files:");
645+
console.dir(ignoredFiles);
646+
console.log("current file:");
647+
console.log(idWithoutQueryAndHash);
648+
649+
const isIgnoredFile = ignoredFiles?.some((file) => idWithoutQueryAndHash.endsWith(file));
650+
if (isIgnoredFile) {
651+
console.log(`FOUND IGNORED FILE: ${idWithoutQueryAndHash}`);
638652
return null;
639653
}
640654

0 commit comments

Comments
 (0)