|
1 | 1 | import { CodeInjection, containsOnlyImports, stripQueryAndHashFromPath } from './utils'; |
2 | | -import { createOxcComponentNameAnnotateHooks, getOxcParseAstAsync } from './component-annotation-oxc'; |
3 | | -import type { ComponentAnnotationTransformMeta, ParseAstAsync } from './component-annotation-oxc-ast'; |
4 | | -import type { Logger } from './logger'; |
5 | 2 |
|
6 | 3 | /** |
7 | 4 | * Checks if a file is a JavaScript file based on its extension. |
@@ -43,45 +40,7 @@ export function shouldSkipCodeInjection(code: string, facadeModuleId: string | n |
43 | 40 | export { globFiles } from './glob'; |
44 | 41 | export { getCodeInjectionPosition } from './get-code-injection-position'; |
45 | 42 |
|
46 | | -const PARSER_UNAVAILABLE_MESSAGE = |
47 | | - 'Could not load `oxc-parser` for this platform. React components will not be annotated.'; |
48 | | - |
49 | | -// Module level, because the Turbopack loader creates new hooks for |
50 | | -// every file. |
51 | | -let warnedParserUnavailable = false; |
52 | | - |
53 | | -// eslint-disable-next-line @typescript-eslint/explicit-function-return-type |
54 | | -export function createComponentNameAnnotateHooks( |
55 | | - ignoredComponents: string[], |
56 | | - injectIntoHtml: boolean, |
57 | | - options: { getParseAstAsync?: () => Promise<ParseAstAsync | null>; logger?: Logger } = {}, |
58 | | -) { |
59 | | - const hooks = createOxcComponentNameAnnotateHooks( |
60 | | - ignoredComponents, |
61 | | - async () => { |
62 | | - const parseAstAsync = (await options.getParseAstAsync?.()) ?? (await getOxcParseAstAsync()); |
63 | | - |
64 | | - if (!parseAstAsync && !warnedParserUnavailable) { |
65 | | - warnedParserUnavailable = true; |
66 | | - if (options.logger) { |
67 | | - options.logger.warn(PARSER_UNAVAILABLE_MESSAGE); |
68 | | - } else { |
69 | | - // eslint-disable-next-line no-console |
70 | | - console.warn(`[@sentry/bundler-plugins] ${PARSER_UNAVAILABLE_MESSAGE}`); |
71 | | - } |
72 | | - } |
73 | | - |
74 | | - return parseAstAsync; |
75 | | - }, |
76 | | - injectIntoHtml, |
77 | | - ); |
78 | | - |
79 | | - return { |
80 | | - transform(this: void, code: string, id: string, meta?: ComponentAnnotationTransformMeta) { |
81 | | - return hooks.transform(code, id, meta); |
82 | | - }, |
83 | | - }; |
84 | | -} |
| 43 | +export { createComponentNameAnnotateHooks } from './component-annotate-hooks'; |
85 | 44 |
|
86 | 45 | export function getDebugIdSnippet(debugId: string): CodeInjection { |
87 | 46 | return new CodeInjection( |
|
0 commit comments