@sentry/bundler-plugins 11.0.0 → 11.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -11
- package/build/cjs/core/component-annotate-hooks.js +32 -0
- package/build/cjs/core/component-annotate-hooks.js.map +1 -0
- package/build/cjs/core/component-annotation-oxc-ast.js.map +1 -1
- package/build/cjs/core/component-annotation-oxc-jsx.js +64 -6
- package/build/cjs/core/component-annotation-oxc-jsx.js.map +1 -1
- package/build/cjs/core/component-annotation-oxc-walk.js +23 -2
- package/build/cjs/core/component-annotation-oxc-walk.js.map +1 -1
- package/build/cjs/core/component-annotation-oxc.js +21 -12
- package/build/cjs/core/component-annotation-oxc.js.map +1 -1
- package/build/cjs/core/index.js +2 -61
- package/build/cjs/core/index.js.map +1 -1
- package/build/cjs/core/version.js +1 -1
- package/build/cjs/core/version.js.map +1 -1
- package/build/cjs/loader-utils/index.js +10 -0
- package/build/cjs/loader-utils/index.js.map +1 -0
- package/build/cjs/rollup/index.js +10 -31
- package/build/cjs/rollup/index.js.map +1 -1
- package/build/cjs/webpack/index.js +4 -2
- package/build/cjs/webpack/index.js.map +1 -1
- package/build/esm/core/component-annotate-hooks.js +30 -0
- package/build/esm/core/component-annotate-hooks.js.map +1 -0
- package/build/esm/core/component-annotation-oxc-ast.js.map +1 -1
- package/build/esm/core/component-annotation-oxc-jsx.js +65 -8
- package/build/esm/core/component-annotation-oxc-jsx.js.map +1 -1
- package/build/esm/core/component-annotation-oxc-walk.js +24 -3
- package/build/esm/core/component-annotation-oxc-walk.js.map +1 -1
- package/build/esm/core/component-annotation-oxc.js +21 -12
- package/build/esm/core/component-annotation-oxc.js.map +1 -1
- package/build/esm/core/index.js +3 -62
- package/build/esm/core/index.js.map +1 -1
- package/build/esm/core/version.js +1 -1
- package/build/esm/core/version.js.map +1 -1
- package/build/esm/loader-utils/index.js +3 -0
- package/build/esm/loader-utils/index.js.map +1 -0
- package/build/esm/package.json +1 -1
- package/build/esm/rollup/index.js +10 -31
- package/build/esm/rollup/index.js.map +1 -1
- package/build/esm/webpack/index.js +4 -2
- package/build/esm/webpack/index.js.map +1 -1
- package/build/types/core/component-annotate-hooks.d.ts +9 -0
- package/build/types/core/component-annotate-hooks.d.ts.map +1 -0
- package/build/types/core/component-annotation-oxc-ast.d.ts +1 -1
- package/build/types/core/component-annotation-oxc-ast.d.ts.map +1 -1
- package/build/types/core/component-annotation-oxc-jsx.d.ts +5 -0
- package/build/types/core/component-annotation-oxc-jsx.d.ts.map +1 -1
- package/build/types/core/component-annotation-oxc-walk.d.ts +1 -1
- package/build/types/core/component-annotation-oxc-walk.d.ts.map +1 -1
- package/build/types/core/component-annotation-oxc.d.ts +1 -1
- package/build/types/core/component-annotation-oxc.d.ts.map +1 -1
- package/build/types/core/index.d.ts +1 -17
- package/build/types/core/index.d.ts.map +1 -1
- package/build/types/core/version.d.ts +1 -1
- package/build/types/loader-utils/index.d.ts +3 -0
- package/build/types/loader-utils/index.d.ts.map +1 -0
- package/build/types/rollup/index.d.ts.map +1 -1
- package/build/types/webpack/index.d.ts.map +1 -1
- package/package.json +12 -3
|
@@ -52,22 +52,19 @@ function getMagicString(code, meta) {
|
|
|
52
52
|
}
|
|
53
53
|
return { magicString: new MagicString(code), isNative: false };
|
|
54
54
|
}
|
|
55
|
-
async function annotateWithOxcParser(code,
|
|
56
|
-
const idWithoutQueryAndHash = stripQueryAndHashFromPath(id);
|
|
57
|
-
if (!idWithoutQueryAndHash || !isAnnotationFile(idWithoutQueryAndHash) || !shouldTryParse(code) || shouldSkipIncompatibleFile(idWithoutQueryAndHash)) {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
55
|
+
async function annotateWithOxcParser(code, idWithoutQueryAndHash, ignoredComponents, parseAstAsync, injectIntoHtml, meta) {
|
|
60
56
|
const ast = await parseAstAsync(code, {
|
|
61
57
|
lang: idWithoutQueryAndHash.endsWith(".jsx") ? "jsx" : "tsx"
|
|
62
58
|
});
|
|
63
59
|
if (!isAstNode(ast)) {
|
|
64
|
-
return
|
|
60
|
+
return null;
|
|
65
61
|
}
|
|
66
62
|
const insertions = collectOxcComponentAnnotationInsertions(
|
|
67
63
|
code,
|
|
68
64
|
ast,
|
|
69
65
|
ignoredComponents,
|
|
70
|
-
path__default.basename(idWithoutQueryAndHash)
|
|
66
|
+
path__default.basename(idWithoutQueryAndHash),
|
|
67
|
+
injectIntoHtml
|
|
71
68
|
);
|
|
72
69
|
if (insertions.length === 0) {
|
|
73
70
|
return null;
|
|
@@ -81,25 +78,37 @@ async function annotateWithOxcParser(code, id, ignoredComponents, parseAstAsync,
|
|
|
81
78
|
}
|
|
82
79
|
return {
|
|
83
80
|
code: magicString.toString(),
|
|
81
|
+
// No `file`, because magic-string would then make `source` relative to it
|
|
82
|
+
// and drop the directory from `sources`.
|
|
84
83
|
map: magicString.generateMap?.({
|
|
85
|
-
file: id,
|
|
86
84
|
source: idWithoutQueryAndHash,
|
|
87
85
|
includeContent: true,
|
|
88
86
|
hires: true
|
|
89
87
|
})
|
|
90
88
|
};
|
|
91
89
|
}
|
|
92
|
-
function createOxcComponentNameAnnotateHooks(ignoredComponents, getParseAstAsync) {
|
|
90
|
+
function createOxcComponentNameAnnotateHooks(ignoredComponents, getParseAstAsync, injectIntoHtml = false) {
|
|
93
91
|
return {
|
|
94
92
|
async transform(code, id, meta) {
|
|
93
|
+
const idWithoutQueryAndHash = stripQueryAndHashFromPath(id);
|
|
94
|
+
if (!idWithoutQueryAndHash || !isAnnotationFile(idWithoutQueryAndHash) || !shouldTryParse(code) || shouldSkipIncompatibleFile(idWithoutQueryAndHash)) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
95
97
|
try {
|
|
96
98
|
const parseAstAsync = await getParseAstAsync();
|
|
97
99
|
if (!parseAstAsync) {
|
|
98
|
-
return
|
|
100
|
+
return null;
|
|
99
101
|
}
|
|
100
|
-
return await annotateWithOxcParser(
|
|
102
|
+
return await annotateWithOxcParser(
|
|
103
|
+
code,
|
|
104
|
+
idWithoutQueryAndHash,
|
|
105
|
+
ignoredComponents,
|
|
106
|
+
parseAstAsync,
|
|
107
|
+
injectIntoHtml,
|
|
108
|
+
meta
|
|
109
|
+
);
|
|
101
110
|
} catch {
|
|
102
|
-
return
|
|
111
|
+
return null;
|
|
103
112
|
}
|
|
104
113
|
}
|
|
105
114
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-annotation-oxc.js","sources":["../../../src/core/component-annotation-oxc.ts"],"sourcesContent":["import path from 'node:path';\n\nimport MagicString from 'magic-string';\n\nimport { KNOWN_INCOMPATIBLE_PLUGINS } from '../babel-plugin/constants';\nimport { stripQueryAndHashFromPath } from './utils';\nimport { isAstNode } from './component-annotation-oxc-ast';\nimport { collectOxcComponentAnnotationInsertions } from './component-annotation-oxc-walk';\nimport type {\n AttributeInsertion,\n ComponentAnnotationTransformMeta,\n ComponentAnnotationTransformResult,\n MagicStringLike,\n ParseAstAsync,\n} from './component-annotation-oxc-ast';\n\nexport type {\n ComponentAnnotationTransformMeta,\n ComponentAnnotationTransformResult,\n} from './component-annotation-oxc-ast';\n\nlet oxcParseAstAsyncPromise: Promise<ParseAstAsync | null> | undefined;\n\nexport function getOxcParseAstAsync(): Promise<ParseAstAsync | null> {\n if (!oxcParseAstAsyncPromise) {\n oxcParseAstAsyncPromise = import('oxc-parser')\n .then(({ parse }): ParseAstAsync => {\n return async (code, { lang }) => {\n // preserveParens: false matches the AST Vite 8 produces. The walker\n // does not look through ParenthesizedExpression nodes.\n const { program, errors } = await parse(`component.${lang}`, code, { lang, preserveParens: false });\n\n if (errors.length > 0) {\n throw new Error(errors[0]?.message);\n }\n\n return program;\n };\n })\n .catch(() => null);\n }\n\n return oxcParseAstAsyncPromise;\n}\n\n// Keep this as a superset of JSX tag starts
|
|
1
|
+
{"version":3,"file":"component-annotation-oxc.js","sources":["../../../src/core/component-annotation-oxc.ts"],"sourcesContent":["import path from 'node:path';\n\nimport MagicString from 'magic-string';\n\nimport { KNOWN_INCOMPATIBLE_PLUGINS } from '../babel-plugin/constants';\nimport { stripQueryAndHashFromPath } from './utils';\nimport { isAstNode } from './component-annotation-oxc-ast';\nimport { collectOxcComponentAnnotationInsertions } from './component-annotation-oxc-walk';\nimport type {\n AttributeInsertion,\n ComponentAnnotationTransformMeta,\n ComponentAnnotationTransformResult,\n MagicStringLike,\n ParseAstAsync,\n} from './component-annotation-oxc-ast';\n\nexport type {\n ComponentAnnotationTransformMeta,\n ComponentAnnotationTransformResult,\n} from './component-annotation-oxc-ast';\n\nlet oxcParseAstAsyncPromise: Promise<ParseAstAsync | null> | undefined;\n\nexport function getOxcParseAstAsync(): Promise<ParseAstAsync | null> {\n if (!oxcParseAstAsyncPromise) {\n oxcParseAstAsyncPromise = import('oxc-parser')\n .then(({ parse }): ParseAstAsync => {\n return async (code, { lang }) => {\n // preserveParens: false matches the AST Vite 8 produces. The walker\n // does not look through ParenthesizedExpression nodes.\n const { program, errors } = await parse(`component.${lang}`, code, { lang, preserveParens: false });\n\n if (errors.length > 0) {\n throw new Error(errors[0]?.message);\n }\n\n return program;\n };\n })\n .catch(() => null);\n }\n\n return oxcParseAstAsyncPromise;\n}\n\n// Keep this as a superset of all JSX tag starts, because a miss skips the file.\nconst JSX_TAG_START_REGEXP = /<[$_\\p{ID_Start}][$_\\u200c\\u200d\\p{ID_Continue}.:-]*|<>/u;\nconst JSX_FILE_REGEXP = /\\.[jt]sx$/;\n\nfunction isAnnotationFile(idWithoutQueryAndHash: string): boolean {\n if (idWithoutQueryAndHash.match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n return false;\n }\n\n return JSX_FILE_REGEXP.test(idWithoutQueryAndHash);\n}\n\nfunction shouldTryParse(code: string): boolean {\n return JSX_TAG_START_REGEXP.test(code);\n}\n\nfunction shouldSkipIncompatibleFile(idWithoutQueryAndHash: string): boolean {\n return KNOWN_INCOMPATIBLE_PLUGINS.some(pluginName => {\n return (\n idWithoutQueryAndHash.includes(`/node_modules/${pluginName}/`) ||\n idWithoutQueryAndHash.includes(`\\\\node_modules\\\\${pluginName}\\\\`)\n );\n });\n}\n\nfunction escapeAttributeValue(value: string): string {\n return value.replace(/&/g, '&').replace(/\"/g, '"');\n}\n\nfunction makeAttributeText(\n code: string,\n insertionOffset: number,\n attributes: AttributeInsertion['attributes'],\n): string {\n const previousCharIsWhitespace = insertionOffset > 0 && /\\s/.test(code[insertionOffset - 1] ?? '');\n const prefix = previousCharIsWhitespace ? '' : ' ';\n const suffix = previousCharIsWhitespace && code[insertionOffset] === '/' ? ' ' : '';\n const attributeText = attributes.map(([name, value]) => `${name}=\"${escapeAttributeValue(value)}\"`).join(' ');\n\n return `${prefix}${attributeText}${suffix}`;\n}\n\nfunction getMagicString(\n code: string,\n meta?: ComponentAnnotationTransformMeta,\n): { magicString: MagicStringLike; isNative: boolean } {\n if (meta?.magicString) {\n return { magicString: meta.magicString, isNative: true };\n }\n\n return { magicString: new MagicString(code), isNative: false };\n}\n\nasync function annotateWithOxcParser(\n code: string,\n idWithoutQueryAndHash: string,\n ignoredComponents: string[],\n parseAstAsync: ParseAstAsync,\n injectIntoHtml: boolean,\n meta?: ComponentAnnotationTransformMeta,\n): Promise<ComponentAnnotationTransformResult> {\n const ast = await parseAstAsync(code, {\n lang: idWithoutQueryAndHash.endsWith('.jsx') ? 'jsx' : 'tsx',\n });\n\n if (!isAstNode(ast)) {\n return null;\n }\n\n const insertions = collectOxcComponentAnnotationInsertions(\n code,\n ast,\n ignoredComponents,\n path.basename(idWithoutQueryAndHash),\n injectIntoHtml,\n );\n\n if (insertions.length === 0) {\n return null;\n }\n\n const { magicString, isNative } = getMagicString(code, meta);\n\n for (const insertion of insertions) {\n magicString.appendLeft(insertion.offset, makeAttributeText(code, insertion.offset, insertion.attributes));\n }\n\n if (isNative) {\n return { code: magicString as unknown as string };\n }\n\n return {\n code: magicString.toString(),\n // No `file`, because magic-string would then make `source` relative to it\n // and drop the directory from `sources`.\n map: magicString.generateMap?.({\n source: idWithoutQueryAndHash,\n includeContent: true,\n hires: true,\n }),\n };\n}\n\nexport function createOxcComponentNameAnnotateHooks(\n ignoredComponents: string[],\n getParseAstAsync: () => Promise<ParseAstAsync | null>,\n injectIntoHtml = false,\n): {\n transform(\n code: string,\n id: string,\n meta?: ComponentAnnotationTransformMeta,\n ): Promise<ComponentAnnotationTransformResult>;\n} {\n return {\n async transform(code, id, meta) {\n const idWithoutQueryAndHash = stripQueryAndHashFromPath(id);\n\n if (\n !idWithoutQueryAndHash ||\n !isAnnotationFile(idWithoutQueryAndHash) ||\n !shouldTryParse(code) ||\n shouldSkipIncompatibleFile(idWithoutQueryAndHash)\n ) {\n return null;\n }\n\n try {\n const parseAstAsync = await getParseAstAsync();\n\n if (!parseAstAsync) {\n return null;\n }\n\n return await annotateWithOxcParser(\n code,\n idWithoutQueryAndHash,\n ignoredComponents,\n parseAstAsync,\n injectIntoHtml,\n meta,\n );\n } catch {\n // Leave files the parser cannot read unchanged. The bundler reports the syntax error.\n return null;\n }\n },\n };\n}\n"],"names":["path"],"mappings":";;;;;;;AAqBA,IAAI,uBAAA;AAEG,SAAS,mBAAA,GAAqD;AACnE,EAAA,IAAI,CAAC,uBAAA,EAAyB;AAC5B,IAAA,uBAAA,GAA0B,OAAO,YAAY,CAAA,CAC1C,KAAK,CAAC,EAAE,OAAM,KAAqB;AAClC,MAAA,OAAO,OAAO,IAAA,EAAM,EAAE,IAAA,EAAK,KAAM;AAG/B,QAAA,MAAM,EAAE,OAAA,EAAS,MAAA,EAAO,GAAI,MAAM,KAAA,CAAM,CAAA,UAAA,EAAa,IAAI,CAAA,CAAA,EAAI,IAAA,EAAM,EAAE,IAAA,EAAM,cAAA,EAAgB,OAAO,CAAA;AAElG,QAAA,IAAI,MAAA,CAAO,SAAS,CAAA,EAAG;AACrB,UAAA,MAAM,IAAI,KAAA,CAAM,MAAA,CAAO,CAAC,GAAG,OAAO,CAAA;AAAA,QACpC;AAEA,QAAA,OAAO,OAAA;AAAA,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js
CHANGED
|
@@ -1,26 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { stripQueryAndHashFromPath, CodeInjection, containsOnlyImports } from './utils.js';
|
|
1
|
+
import { CodeInjection, stripQueryAndHashFromPath, containsOnlyImports } from './utils.js';
|
|
3
2
|
export { generateModuleMetadataInjectorCode, generateReleaseInjectorCode, replaceBooleanFlagsInCode, stringToUUID } from './utils.js';
|
|
4
3
|
export { globFiles } from './glob.js';
|
|
5
4
|
export { getCodeInjectionPosition } from './get-code-injection-position.js';
|
|
5
|
+
export { createComponentNameAnnotateHooks } from './component-annotate-hooks.js';
|
|
6
6
|
export { createSentryBuildPluginManager } from './build-plugin-manager.js';
|
|
7
7
|
export { addDebugIdToEmittedArtifacts, createDebugIdUploadFunction, stampDebugId } from './debug-id-upload.js';
|
|
8
8
|
|
|
9
|
-
let babelAnnotationRuntimePromise;
|
|
10
|
-
function loadBabelAnnotationRuntime() {
|
|
11
|
-
if (!babelAnnotationRuntimePromise) {
|
|
12
|
-
babelAnnotationRuntimePromise = Promise.all([import('@babel/core'), import('../babel-plugin/index.js')]).then(
|
|
13
|
-
([babel, babelPlugin]) => {
|
|
14
|
-
return {
|
|
15
|
-
transformAsync: babel.transformAsync,
|
|
16
|
-
componentNameAnnotatePlugin: babelPlugin.default,
|
|
17
|
-
experimentalComponentNameAnnotatePlugin: babelPlugin.experimentalComponentNameAnnotatePlugin
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
return babelAnnotationRuntimePromise;
|
|
23
|
-
}
|
|
24
9
|
function isJsFile(fileName) {
|
|
25
10
|
const cleanFileName = stripQueryAndHashFromPath(fileName);
|
|
26
11
|
return [".js", ".mjs", ".cjs"].some((ext) => cleanFileName.endsWith(ext));
|
|
@@ -34,55 +19,11 @@ function shouldSkipCodeInjection(code, facadeModuleId) {
|
|
|
34
19
|
}
|
|
35
20
|
return false;
|
|
36
21
|
}
|
|
37
|
-
function createComponentNameAnnotateHooks(ignoredComponents, injectIntoHtml) {
|
|
38
|
-
return {
|
|
39
|
-
async transform(code, id) {
|
|
40
|
-
const idWithoutQueryAndHash = stripQueryAndHashFromPath(id);
|
|
41
|
-
if (idWithoutQueryAndHash.match(/\\node_modules\\|\/node_modules\//)) {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
if (![".jsx", ".tsx"].some((ending) => idWithoutQueryAndHash.endsWith(ending))) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
const parserPlugins = [];
|
|
48
|
-
if (idWithoutQueryAndHash.endsWith(".jsx")) {
|
|
49
|
-
parserPlugins.push("jsx");
|
|
50
|
-
} else if (idWithoutQueryAndHash.endsWith(".tsx")) {
|
|
51
|
-
parserPlugins.push("jsx", "typescript");
|
|
52
|
-
}
|
|
53
|
-
const { transformAsync, componentNameAnnotatePlugin, experimentalComponentNameAnnotatePlugin } = await loadBabelAnnotationRuntime();
|
|
54
|
-
const plugin = injectIntoHtml ? experimentalComponentNameAnnotatePlugin : componentNameAnnotatePlugin;
|
|
55
|
-
try {
|
|
56
|
-
const result = await transformAsync(code, {
|
|
57
|
-
plugins: [[plugin, { ignoredComponents }]],
|
|
58
|
-
filename: id,
|
|
59
|
-
sourceFileName: idWithoutQueryAndHash,
|
|
60
|
-
parserOpts: {
|
|
61
|
-
sourceType: "module",
|
|
62
|
-
allowAwaitOutsideFunction: true,
|
|
63
|
-
plugins: parserPlugins
|
|
64
|
-
},
|
|
65
|
-
generatorOpts: {
|
|
66
|
-
decoratorsBeforeExport: true
|
|
67
|
-
},
|
|
68
|
-
sourceMaps: true
|
|
69
|
-
});
|
|
70
|
-
return {
|
|
71
|
-
code: result?.code ?? code,
|
|
72
|
-
map: result?.map
|
|
73
|
-
};
|
|
74
|
-
} catch (e) {
|
|
75
|
-
debug.error(`Failed to apply react annotate plugin`, e);
|
|
76
|
-
}
|
|
77
|
-
return { code };
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
22
|
function getDebugIdSnippet(debugId) {
|
|
82
23
|
return new CodeInjection(
|
|
83
24
|
`var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="${debugId}",e._sentryDebugIdIdentifier="sentry-dbid-${debugId}");`
|
|
84
25
|
);
|
|
85
26
|
}
|
|
86
27
|
|
|
87
|
-
export { CodeInjection,
|
|
28
|
+
export { CodeInjection, getDebugIdSnippet, isJsFile, shouldSkipCodeInjection };
|
|
88
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/core/index.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/core/index.ts"],"sourcesContent":["import { CodeInjection, containsOnlyImports, stripQueryAndHashFromPath } from './utils';\n\n/**\n * Checks if a file is a JavaScript file based on its extension.\n * Handles query strings and hashes in the filename.\n */\nexport function isJsFile(fileName: string): boolean {\n const cleanFileName = stripQueryAndHashFromPath(fileName);\n return ['.js', '.mjs', '.cjs'].some(ext => cleanFileName.endsWith(ext));\n}\n\n/**\n * Checks if a chunk should be skipped for code injection\n *\n * This is necessary to handle Vite's MPA (multi-page application) mode where\n * HTML entry points create \"facade\" chunks that should not contain injected code.\n * See: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/829\n *\n * However, in SPA mode, the main bundle also has an HTML facade but contains\n * substantial application code. We should NOT skip injection for these bundles.\n *\n * @param code - The chunk's code content\n * @param facadeModuleId - The facade module ID (if any) - HTML files create facade chunks\n * @returns true if the chunk should be skipped\n */\nexport function shouldSkipCodeInjection(code: string, facadeModuleId: string | null | undefined): boolean {\n // Skip empty chunks - these are placeholder chunks that should be optimized away\n if (code.trim().length === 0) {\n return true;\n }\n\n // For HTML facade chunks, only skip if they contain only import statements\n if (facadeModuleId && stripQueryAndHashFromPath(facadeModuleId).endsWith('.html')) {\n return containsOnlyImports(code);\n }\n\n return false;\n}\n\nexport { globFiles } from './glob';\nexport { getCodeInjectionPosition } from './get-code-injection-position';\n\nexport { createComponentNameAnnotateHooks } from './component-annotate-hooks';\n\nexport function getDebugIdSnippet(debugId: string): CodeInjection {\n return new CodeInjection(\n `var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]=\"${debugId}\",e._sentryDebugIdIdentifier=\"sentry-dbid-${debugId}\");`,\n );\n}\n\nexport type { Logger } from './logger';\nexport type { Options, SentrySDKBuildFlags } from './types';\nexport {\n CodeInjection,\n replaceBooleanFlagsInCode,\n stringToUUID,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n} from './utils';\nexport { createSentryBuildPluginManager } from './build-plugin-manager';\nexport { createDebugIdUploadFunction, addDebugIdToEmittedArtifacts, stampDebugId } from './debug-id-upload';\n"],"names":[],"mappings":";;;;;;;;AAMO,SAAS,SAAS,QAAA,EAA2B;AAClD,EAAA,MAAM,aAAA,GAAgB,0BAA0B,QAAQ,CAAA;AACxD,EAAA,OAAO,CAAC,KAAA,EAAO,MAAA,EAAQ,MAAM,CAAA,CAAE,KAAK,CAAA,GAAA,KAAO,aAAA,CAAc,QAAA,CAAS,GAAG,CAAC,CAAA;AACxE;AAgBO,SAAS,uBAAA,CAAwB,MAAc,cAAA,EAAoD;AAExG,EAAA,IAAI,IAAA,CAAK,IAAA,EAAK,CAAE,MAAA,KAAW,CAAA,EAAG;AAC5B,IAAA,OAAO,IAAA;AAAA,EACT;AAGA,EAAA,IAAI,kBAAkB,yBAAA,CAA0B,cAAc,CAAA,CAAE,QAAA,CAAS,OAAO,CAAA,EAAG;AACjF,IAAA,OAAO,oBAAoB,IAAI,CAAA;AAAA,EACjC;AAEA,EAAA,OAAO,KAAA;AACT;AAOO,SAAS,kBAAkB,OAAA,EAAgC;AAChE,EAAA,OAAO,IAAI,aAAA;AAAA,IACT,CAAA,4FAAA,EAA+F,OAAO,CAAA,0CAAA,EAA6C,OAAO,CAAA,GAAA;AAAA,GAC5J;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sources":["../../../src/core/version.ts"],"sourcesContent":["export const LIB_VERSION = \"11.
|
|
1
|
+
{"version":3,"file":"version.js","sources":["../../../src/core/version.ts"],"sourcesContent":["export const LIB_VERSION = \"11.1.0\";\n"],"names":[],"mappings":"AAAO,MAAM,WAAA,GAAc;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"11.
|
|
1
|
+
{"type":"module","version":"11.1.0","sideEffects":["./sentry-release-injection-file.js","./sentry-esbuild-debugid-injection-file.js"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isJsFile, shouldSkipCodeInjection, getDebugIdSnippet } from '../core/index.js';
|
|
2
2
|
import MagicString from 'magic-string';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
4
|
import { createRequire } from 'node:module';
|
|
5
5
|
import { createSentryBuildPluginManager } from '../core/build-plugin-manager.js';
|
|
6
6
|
import { CodeInjection, generateReleaseInjectorCode, generateModuleMetadataInjectorCode, stringToUUID, replaceBooleanFlagsInCode } from '../core/utils.js';
|
|
7
|
+
import { createComponentNameAnnotateHooks } from '../core/component-annotate-hooks.js';
|
|
7
8
|
import { globFiles } from '../core/glob.js';
|
|
8
9
|
import { stampDebugId, createDebugIdUploadFunction } from '../core/debug-id-upload.js';
|
|
9
10
|
import { getCodeInjectionPosition } from '../core/get-code-injection-position.js';
|
|
@@ -88,25 +89,13 @@ function _rollupPluginInternal(userOptions = {}, buildTool, buildToolMajorVersio
|
|
|
88
89
|
}
|
|
89
90
|
const transformAnnotations = options.reactComponentAnnotation?.enabled ? createComponentNameAnnotateHooks(
|
|
90
91
|
options.reactComponentAnnotation?.ignoredComponents || [],
|
|
91
|
-
!!options.reactComponentAnnotation?._experimentalInjectIntoHtml
|
|
92
|
+
!!options.reactComponentAnnotation?._experimentalInjectIntoHtml,
|
|
93
|
+
{
|
|
94
|
+
// Vite 8 already loads an oxc-based parser, so reuse it.
|
|
95
|
+
getParseAstAsync: buildTool === "vite" && buildToolMajorVersion === "8" ? getViteParseAstAsync : void 0,
|
|
96
|
+
logger
|
|
97
|
+
}
|
|
92
98
|
) : void 0;
|
|
93
|
-
const transformFastAnnotations = options.reactComponentAnnotation?.enabled && !options.reactComponentAnnotation?._experimentalInjectIntoHtml ? /* @__PURE__ */ (() => {
|
|
94
|
-
let fastAnnotationHooksPromise;
|
|
95
|
-
return {
|
|
96
|
-
transform(code, id, meta) {
|
|
97
|
-
if (!fastAnnotationHooksPromise) {
|
|
98
|
-
fastAnnotationHooksPromise = import('../core/component-annotation-oxc.js').then(
|
|
99
|
-
({ createOxcComponentNameAnnotateHooks, getOxcParseAstAsync }) => createOxcComponentNameAnnotateHooks(
|
|
100
|
-
options.reactComponentAnnotation?.ignoredComponents || [],
|
|
101
|
-
// Vite 8 already loads an oxc-based parser, so reuse it.
|
|
102
|
-
buildTool === "vite" && buildToolMajorVersion === "8" ? getViteParseAstAsync : getOxcParseAstAsync
|
|
103
|
-
)
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
return fastAnnotationHooksPromise.then((hooks) => hooks.transform(code, id, meta));
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
})() : void 0;
|
|
110
99
|
const transformReplace = Object.keys(replacementValues).length > 0;
|
|
111
100
|
const shouldTransform = transformAnnotations || transformReplace;
|
|
112
101
|
function buildStart() {
|
|
@@ -114,18 +103,8 @@ function _rollupPluginInternal(userOptions = {}, buildTool, buildToolMajorVersio
|
|
|
114
103
|
});
|
|
115
104
|
}
|
|
116
105
|
async function transform(code, id, meta) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const result = await transformFastAnnotations.transform(code, id, meta);
|
|
120
|
-
if (result) {
|
|
121
|
-
return result;
|
|
122
|
-
}
|
|
123
|
-
if (result === null) {
|
|
124
|
-
shouldRunBabelAnnotations = false;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
if (shouldRunBabelAnnotations && transformAnnotations?.transform) {
|
|
128
|
-
const result = await transformAnnotations.transform(code, id);
|
|
106
|
+
if (transformAnnotations) {
|
|
107
|
+
const result = await transformAnnotations.transform(code, id, meta);
|
|
129
108
|
if (result) {
|
|
130
109
|
return result;
|
|
131
110
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/rollup/index.ts"],"sourcesContent":["import type { Options } from '../core';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n isJsFile,\n shouldSkipCodeInjection,\n getDebugIdSnippet,\n stringToUUID,\n createDebugIdUploadFunction,\n globFiles,\n createComponentNameAnnotateHooks,\n replaceBooleanFlagsInCode,\n CodeInjection,\n stampDebugId,\n getCodeInjectionPosition,\n} from '../core';\nimport type {\n ComponentAnnotationTransformMeta,\n ComponentAnnotationTransformResult,\n} from '../core/component-annotation-oxc';\nimport type { SourceMap } from 'magic-string';\nimport MagicString from 'magic-string';\nimport * as path from 'node:path';\nimport { createRequire } from 'node:module';\n\n// The subset of Rollup's `TransformResult` that this plugin's `transform`\n// hook actually returns. Defined locally instead of imported from `rollup`\n// because `rollup` is an optional dependency.\ntype TransformResult = { code: string; map?: SourceMap | string | { mappings: string } | null } | null | undefined;\n\n// The subset of Rollup's `OutputBundle` the stamping hook reads.\ntype OutputBundle = Record<\n string,\n | { type: 'chunk'; fileName: string; code: string; sourcemapFileName?: string | null }\n | { type: 'asset'; fileName: string; source: string | Uint8Array }\n>;\n\ntype ViteModule = {\n parseAstAsync?: (code: string, options: { lang: 'jsx' | 'tsx' }) => Promise<unknown>;\n};\n\ntype ViteParseAstAsync = NonNullable<ViteModule['parseAstAsync']>;\ntype FastAnnotationHooks = {\n transform(\n code: string,\n id: string,\n meta?: ComponentAnnotationTransformMeta,\n ): Promise<ComponentAnnotationTransformResult>;\n};\n\nlet viteParseAstAsyncPromise: Promise<ViteParseAstAsync | null> | undefined;\n\nconst JS_MODULE_ID_FILTER = /\\.[cm]?[jt]sx?(?:[?#].*)?$/;\n\nfunction hasExistingDebugID(code: string): boolean {\n // Check if a debug ID has already been injected to avoid duplicate injection (e.g. by another plugin or Sentry CLI)\n const chunkStartSnippet = code.slice(0, 6000);\n const chunkEndSnippet = code.slice(-500);\n\n if (chunkStartSnippet.includes('_sentryDebugIdIdentifier') || chunkEndSnippet.includes('//# debugId=')) {\n return true; // Debug ID already present, skip injection\n }\n\n return false;\n}\n\nfunction getRollupMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Rollup already transpiles this for us\n const req = createRequire(import.meta.url);\n const rollup = req('rollup') as { VERSION?: string };\n return rollup.VERSION?.split('.')[0];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nfunction getViteParseAstAsync(): Promise<ViteParseAstAsync | null> {\n if (!viteParseAstAsyncPromise) {\n viteParseAstAsyncPromise = Promise.resolve()\n .then(async () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Vite is an optional runtime peer for this package\n const viteModule = createRequire(import.meta.url)('vite') as ViteModule;\n\n if (typeof viteModule.parseAstAsync !== 'function') {\n return null;\n }\n\n try {\n await viteModule.parseAstAsync('const x = <div />;', { lang: 'tsx' });\n } catch {\n return null;\n }\n\n return viteModule.parseAstAsync;\n })\n .catch(() => null);\n }\n\n return viteParseAstAsyncPromise;\n}\n\n/**\n * @ignore - this is the internal plugin factory function only used for the Vite plugin!\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function _rollupPluginInternal(\n userOptions: Options = {},\n buildTool: 'rollup' | 'vite',\n buildToolMajorVersion?: string,\n) {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[sentry-${buildTool}-plugin]`,\n buildTool,\n buildToolMajorVersion: buildToolMajorVersion || getRollupMajorVersion(),\n });\n\n const {\n logger,\n normalizedOptions: options,\n bundleSizeOptimizationReplacementValues: replacementValues,\n bundleMetadata,\n createDependencyOnBuildArtifacts,\n } = sentryBuildPluginManager;\n\n if (options.disable) {\n return {\n name: 'sentry-noop-plugin',\n };\n }\n\n if (process.cwd().match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n logger.warn('Running Sentry plugin from within a `node_modules` folder. Some features may not work.');\n }\n\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n const sourcemapsEnabled = options.sourcemaps?.disable !== true;\n const staticInjectionCode = new CodeInjection();\n\n if (!options.release.inject) {\n logger.debug('Release injection disabled via `release.inject` option. Will not inject release.');\n } else if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not inject release. Please set the `release.name` option to identify your release.',\n );\n } else {\n staticInjectionCode.append(\n generateReleaseInjectorCode({\n release: options.release.name,\n injectBuildInformation: options._experiments.injectBuildInformation || false,\n }),\n );\n }\n\n if (Object.keys(bundleMetadata).length > 0) {\n staticInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));\n }\n\n const transformAnnotations = options.reactComponentAnnotation?.enabled\n ? createComponentNameAnnotateHooks(\n options.reactComponentAnnotation?.ignoredComponents || [],\n !!options.reactComponentAnnotation?._experimentalInjectIntoHtml,\n )\n : undefined;\n const transformFastAnnotations =\n options.reactComponentAnnotation?.enabled && !options.reactComponentAnnotation?._experimentalInjectIntoHtml\n ? (() => {\n let fastAnnotationHooksPromise: Promise<FastAnnotationHooks> | undefined;\n\n return {\n transform(code: string, id: string, meta?: ComponentAnnotationTransformMeta) {\n if (!fastAnnotationHooksPromise) {\n fastAnnotationHooksPromise = import('../core/component-annotation-oxc').then(\n ({ createOxcComponentNameAnnotateHooks, getOxcParseAstAsync }) =>\n createOxcComponentNameAnnotateHooks(\n options.reactComponentAnnotation?.ignoredComponents || [],\n // Vite 8 already loads an oxc-based parser, so reuse it.\n buildTool === 'vite' && buildToolMajorVersion === '8'\n ? getViteParseAstAsync\n : getOxcParseAstAsync,\n ),\n );\n }\n\n return fastAnnotationHooksPromise.then(hooks => hooks.transform(code, id, meta));\n },\n };\n })()\n : undefined;\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n const shouldTransform = transformAnnotations || transformReplace;\n\n function buildStart(): void {\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n }\n\n async function transform(\n code: string,\n id: string,\n meta?: ComponentAnnotationTransformMeta,\n ): Promise<TransformResult> {\n // Component annotations are only in user code and boolean flag replacements are\n // only in Sentry code. If we successfully add annotations, we can return early.\n let shouldRunBabelAnnotations = true;\n\n if (transformFastAnnotations?.transform) {\n const result = await transformFastAnnotations.transform(code, id, meta);\n if (result) {\n return result;\n }\n\n if (result === null) {\n shouldRunBabelAnnotations = false;\n }\n }\n\n if (shouldRunBabelAnnotations && transformAnnotations?.transform) {\n const result = await transformAnnotations.transform(code, id);\n if (result) {\n return result;\n }\n }\n\n if (transformReplace) {\n return replaceBooleanFlagsInCode(code, replacementValues);\n }\n\n return null;\n }\n\n function renderChunk(\n code: string,\n chunk: { fileName: string; facadeModuleId?: string | null },\n _?: unknown,\n meta?: { magicString?: MagicString },\n ): {\n code: string;\n map?: SourceMap;\n } | null {\n if (!isJsFile(chunk.fileName)) {\n return null; // returning null means not modifying the chunk at all\n }\n\n // Skip empty chunks and HTML facade chunks (Vite MPA)\n if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {\n return null;\n }\n\n const injectCode = staticInjectionCode.clone();\n\n if (sourcemapsEnabled && !hasExistingDebugID(code)) {\n const debugId = stringToUUID(code); // generate a deterministic debug ID\n injectCode.append(getDebugIdSnippet(debugId));\n }\n\n if (injectCode.isEmpty()) {\n return null;\n }\n\n const ms = meta?.magicString || new MagicString(code, { filename: chunk.fileName });\n const injectionPosition = getCodeInjectionPosition(code);\n const codeToInject = injectionPosition === code.length ? `\\n${injectCode.code()}` : injectCode.code();\n ms.appendLeft(injectionPosition, codeToInject);\n\n // Rolldown can pass a native MagicString instance in meta.magicString\n // https://rolldown.rs/in-depth/native-magic-string#usage-examples\n if (ms?.constructor?.name === 'BindingMagicString') {\n // Rolldown docs say to return the magic string instance directly in this case\n return { code: ms as unknown as string };\n }\n\n return {\n code: ms.toString(),\n map: ms.generateMap({ file: chunk.fileName, hires: 'boundary' }),\n };\n }\n\n /**\n * Stamps debug IDs into the emitted chunks and source maps.\n *\n * `disable-upload` skips the upload routine (which stamps debug IDs into temp copies), so the emitted\n * artifacts get stamped here instead. Not in `renderChunk`: minifiers running after it would strip the\n * comment. Rollup computes `[hash]` file names before this hook, so only plugins that hash the final\n * assets afterwards (e.g. subresource integrity) see the stamped content.\n */\n function generateBundle(_outputOptions: unknown, bundle: OutputBundle): void {\n for (const output of Object.values(bundle)) {\n if (output.type !== 'chunk' || !isJsFile(output.fileName)) {\n continue;\n }\n\n const sourceMapAsset = bundle[output.sourcemapFileName ?? `${output.fileName}.map`];\n const sourceMapSource =\n sourceMapAsset?.type === 'asset' && typeof sourceMapAsset.source === 'string'\n ? sourceMapAsset.source\n : undefined;\n\n const stamped = stampDebugId(output.code, sourceMapSource);\n if (!stamped) {\n continue;\n }\n\n output.code = stamped.bundleSource;\n if (stamped.sourceMapSource !== undefined && sourceMapAsset?.type === 'asset') {\n sourceMapAsset.source = stamped.sourceMapSource;\n }\n }\n }\n\n async function writeBundle(\n outputOptions: { dir?: string; file?: string },\n bundle: { [fileName: string]: unknown },\n ): Promise<void> {\n try {\n await sentryBuildPluginManager.createRelease();\n\n if (sourcemapsEnabled && options.sourcemaps?.disable !== 'disable-upload') {\n if (outputOptions.dir) {\n const outputDir = outputOptions.dir;\n const JS_AND_MAP_PATTERNS = [\n '/**/*.js',\n '/**/*.mjs',\n '/**/*.cjs',\n '/**/*.js.map',\n '/**/*.mjs.map',\n '/**/*.cjs.map',\n ].map(q => `${q}?(\\\\?*)?(#*)`); // We want to allow query and hash strings at the end of files\n const buildArtifacts = await globFiles(JS_AND_MAP_PATTERNS, { root: outputDir });\n await upload(buildArtifacts);\n } else if (outputOptions.file) {\n await upload([outputOptions.file]);\n } else {\n const buildArtifacts = Object.keys(bundle).map(asset => path.join(path.resolve(), asset));\n await upload(buildArtifacts);\n }\n }\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n }\n\n const name = `sentry-${buildTool}-plugin`;\n const transformHook =\n buildTool === 'vite'\n ? {\n filter: { id: JS_MODULE_ID_FILTER },\n handler: transform,\n }\n : transform;\n\n return {\n name,\n buildStart,\n ...(shouldTransform ? { transform: transformHook } : {}),\n renderChunk,\n ...(options.sourcemaps?.disable === 'disable-upload'\n ? { generateBundle: { order: 'pre' as const, handler: generateBundle } }\n : {}),\n writeBundle,\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-explicit-any\nexport function sentryRollupPlugin(userOptions: Options = {}): any {\n // We return an array here so we don't break backwards compatibility with what\n // unplugin used to return\n return [_rollupPluginInternal(userOptions, 'rollup')];\n}\n\nexport type { Options as SentryRollupPluginOptions } from '../core';\n"],"names":[],"mappings":";;;;;;;;;;AAmDA,IAAI,wBAAA;AAEJ,MAAM,mBAAA,GAAsB,4BAAA;AAE5B,SAAS,mBAAmB,IAAA,EAAuB;AAEjD,EAAA,MAAM,iBAAA,GAAoB,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,GAAI,CAAA;AAC5C,EAAA,MAAM,eAAA,GAAkB,IAAA,CAAK,KAAA,CAAM,IAAI,CAAA;AAEvC,EAAA,IAAI,kBAAkB,QAAA,CAAS,0BAA0B,KAAK,eAAA,CAAgB,QAAA,CAAS,cAAc,CAA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,CAAc,IAAI,CAAC,CAAA;AAAA,QACnC,CAAA,MAAO;AACL,UAAA,MAAM,cAAA,GAAiB,MAAA,CAAO,IAAA,CAAK,MAAM,CAAA,CAAE,GAAA,CAAI,CAAA,KAAA,KAAS,IAAA,CAAK,IAAA,CAAK,IAAA,CAAK,OAAA,EAAQ,EAAG,KAAK,CAAC,CAAA;AACxF,UAAA,MAAM,OAAO,cAAc,CAAA;AAAA,QAC7B;AAAA,MACF;AAAA,IACF,CAAA,SAAE;AACA,MAAA,oCAAA,EAAqC;AACrC,MAAA,MAAM,yBAAyB,eAAA,EAAgB;AAAA,IACjD;AAAA,EACF;AAEA,EAAA,MAAM,IAAA,GAAO,UAAU,SAAS,CAAA,OAAA,CAAA;AAChC,EAAA,MAAM,aAAA,GACJ,cAAc,MAAA,GACV;AAAA,IACE,MAAA,EAAQ,EAAE,EAAA,EAAI,mBAAA,EAAoB;AAAA,IAClC,OAAA,EAAS;AAAA,GACX,GACA,SAAA;AAEN,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,UAAA;AAAA,IACA,GAAI,eAAA,GAAkB,EAAE,SAAA,EAAW,aAAA,KAAkB,EAAC;AAAA,IACtD,WAAA;AAAA,IACA,GAAI,OAAA,CAAQ,UAAA,EAAY,OAAA,KAAY,mBAChC,EAAE,cAAA,EAAgB,EAAE,KAAA,EAAO,KAAA,EAAgB,OAAA,EAAS,cAAA,EAAe,KACnE,EAAC;AAAA,IACL;AAAA,GACF;AACF;AAGO,SAAS,kBAAA,CAAmB,WAAA,GAAuB,EAAC,EAAQ;AAGjE,EAAA,OAAO,CAAC,qBAAA,CAAsB,WAAA,EAAa,QAAQ,CAAC,CAAA;AACtD;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/rollup/index.ts"],"sourcesContent":["import type { Options } from '../core';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n isJsFile,\n shouldSkipCodeInjection,\n getDebugIdSnippet,\n stringToUUID,\n createDebugIdUploadFunction,\n globFiles,\n createComponentNameAnnotateHooks,\n replaceBooleanFlagsInCode,\n CodeInjection,\n stampDebugId,\n getCodeInjectionPosition,\n} from '../core';\nimport type { ComponentAnnotationTransformMeta } from '../core/component-annotation-oxc';\nimport type { SourceMap } from 'magic-string';\nimport MagicString from 'magic-string';\nimport * as path from 'node:path';\nimport { createRequire } from 'node:module';\n\n// The subset of Rollup's `TransformResult` that this plugin's `transform`\n// hook actually returns. Defined locally instead of imported from `rollup`\n// because `rollup` is an optional dependency.\ntype TransformResult = { code: string; map?: SourceMap | string | { mappings: string } | null } | null | undefined;\n\n// The subset of Rollup's `OutputBundle` the stamping hook reads.\ntype OutputBundle = Record<\n string,\n | { type: 'chunk'; fileName: string; code: string; sourcemapFileName?: string | null }\n | { type: 'asset'; fileName: string; source: string | Uint8Array }\n>;\n\ntype ViteModule = {\n parseAstAsync?: (code: string, options: { lang: 'jsx' | 'tsx' }) => Promise<unknown>;\n};\n\ntype ViteParseAstAsync = NonNullable<ViteModule['parseAstAsync']>;\n\nlet viteParseAstAsyncPromise: Promise<ViteParseAstAsync | null> | undefined;\n\nconst JS_MODULE_ID_FILTER = /\\.[cm]?[jt]sx?(?:[?#].*)?$/;\n\nfunction hasExistingDebugID(code: string): boolean {\n // Check if a debug ID has already been injected to avoid duplicate injection (e.g. by another plugin or Sentry CLI)\n const chunkStartSnippet = code.slice(0, 6000);\n const chunkEndSnippet = code.slice(-500);\n\n if (chunkStartSnippet.includes('_sentryDebugIdIdentifier') || chunkEndSnippet.includes('//# debugId=')) {\n return true; // Debug ID already present, skip injection\n }\n\n return false;\n}\n\nfunction getRollupMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Rollup already transpiles this for us\n const req = createRequire(import.meta.url);\n const rollup = req('rollup') as { VERSION?: string };\n return rollup.VERSION?.split('.')[0];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nfunction getViteParseAstAsync(): Promise<ViteParseAstAsync | null> {\n if (!viteParseAstAsyncPromise) {\n viteParseAstAsyncPromise = Promise.resolve()\n .then(async () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Vite is an optional runtime peer for this package\n const viteModule = createRequire(import.meta.url)('vite') as ViteModule;\n\n if (typeof viteModule.parseAstAsync !== 'function') {\n return null;\n }\n\n try {\n await viteModule.parseAstAsync('const x = <div />;', { lang: 'tsx' });\n } catch {\n return null;\n }\n\n return viteModule.parseAstAsync;\n })\n .catch(() => null);\n }\n\n return viteParseAstAsyncPromise;\n}\n\n/**\n * @ignore - this is the internal plugin factory function only used for the Vite plugin!\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function _rollupPluginInternal(\n userOptions: Options = {},\n buildTool: 'rollup' | 'vite',\n buildToolMajorVersion?: string,\n) {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[sentry-${buildTool}-plugin]`,\n buildTool,\n buildToolMajorVersion: buildToolMajorVersion || getRollupMajorVersion(),\n });\n\n const {\n logger,\n normalizedOptions: options,\n bundleSizeOptimizationReplacementValues: replacementValues,\n bundleMetadata,\n createDependencyOnBuildArtifacts,\n } = sentryBuildPluginManager;\n\n if (options.disable) {\n return {\n name: 'sentry-noop-plugin',\n };\n }\n\n if (process.cwd().match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n logger.warn('Running Sentry plugin from within a `node_modules` folder. Some features may not work.');\n }\n\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n const sourcemapsEnabled = options.sourcemaps?.disable !== true;\n const staticInjectionCode = new CodeInjection();\n\n if (!options.release.inject) {\n logger.debug('Release injection disabled via `release.inject` option. Will not inject release.');\n } else if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not inject release. Please set the `release.name` option to identify your release.',\n );\n } else {\n staticInjectionCode.append(\n generateReleaseInjectorCode({\n release: options.release.name,\n injectBuildInformation: options._experiments.injectBuildInformation || false,\n }),\n );\n }\n\n if (Object.keys(bundleMetadata).length > 0) {\n staticInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));\n }\n\n const transformAnnotations = options.reactComponentAnnotation?.enabled\n ? createComponentNameAnnotateHooks(\n options.reactComponentAnnotation?.ignoredComponents || [],\n !!options.reactComponentAnnotation?._experimentalInjectIntoHtml,\n {\n // Vite 8 already loads an oxc-based parser, so reuse it.\n getParseAstAsync: buildTool === 'vite' && buildToolMajorVersion === '8' ? getViteParseAstAsync : undefined,\n logger,\n },\n )\n : undefined;\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n const shouldTransform = transformAnnotations || transformReplace;\n\n function buildStart(): void {\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n }\n\n async function transform(\n code: string,\n id: string,\n meta?: ComponentAnnotationTransformMeta,\n ): Promise<TransformResult> {\n // Component annotations are only in user code and boolean flag replacements are\n // only in Sentry code. If we successfully add annotations, we can return early.\n if (transformAnnotations) {\n const result = await transformAnnotations.transform(code, id, meta);\n if (result) {\n return result;\n }\n }\n\n if (transformReplace) {\n return replaceBooleanFlagsInCode(code, replacementValues);\n }\n\n return null;\n }\n\n function renderChunk(\n code: string,\n chunk: { fileName: string; facadeModuleId?: string | null },\n _?: unknown,\n meta?: { magicString?: MagicString },\n ): {\n code: string;\n map?: SourceMap;\n } | null {\n if (!isJsFile(chunk.fileName)) {\n return null; // returning null means not modifying the chunk at all\n }\n\n // Skip empty chunks and HTML facade chunks (Vite MPA)\n if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {\n return null;\n }\n\n const injectCode = staticInjectionCode.clone();\n\n if (sourcemapsEnabled && !hasExistingDebugID(code)) {\n const debugId = stringToUUID(code); // generate a deterministic debug ID\n injectCode.append(getDebugIdSnippet(debugId));\n }\n\n if (injectCode.isEmpty()) {\n return null;\n }\n\n const ms = meta?.magicString || new MagicString(code, { filename: chunk.fileName });\n const injectionPosition = getCodeInjectionPosition(code);\n const codeToInject = injectionPosition === code.length ? `\\n${injectCode.code()}` : injectCode.code();\n ms.appendLeft(injectionPosition, codeToInject);\n\n // Rolldown can pass a native MagicString instance in meta.magicString\n // https://rolldown.rs/in-depth/native-magic-string#usage-examples\n if (ms?.constructor?.name === 'BindingMagicString') {\n // Rolldown docs say to return the magic string instance directly in this case\n return { code: ms as unknown as string };\n }\n\n return {\n code: ms.toString(),\n map: ms.generateMap({ file: chunk.fileName, hires: 'boundary' }),\n };\n }\n\n /**\n * Stamps debug IDs into the emitted chunks and source maps.\n *\n * `disable-upload` skips the upload routine (which stamps debug IDs into temp copies), so the emitted\n * artifacts get stamped here instead. Not in `renderChunk`: minifiers running after it would strip the\n * comment. Rollup computes `[hash]` file names before this hook, so only plugins that hash the final\n * assets afterwards (e.g. subresource integrity) see the stamped content.\n */\n function generateBundle(_outputOptions: unknown, bundle: OutputBundle): void {\n for (const output of Object.values(bundle)) {\n if (output.type !== 'chunk' || !isJsFile(output.fileName)) {\n continue;\n }\n\n const sourceMapAsset = bundle[output.sourcemapFileName ?? `${output.fileName}.map`];\n const sourceMapSource =\n sourceMapAsset?.type === 'asset' && typeof sourceMapAsset.source === 'string'\n ? sourceMapAsset.source\n : undefined;\n\n const stamped = stampDebugId(output.code, sourceMapSource);\n if (!stamped) {\n continue;\n }\n\n output.code = stamped.bundleSource;\n if (stamped.sourceMapSource !== undefined && sourceMapAsset?.type === 'asset') {\n sourceMapAsset.source = stamped.sourceMapSource;\n }\n }\n }\n\n async function writeBundle(\n outputOptions: { dir?: string; file?: string },\n bundle: { [fileName: string]: unknown },\n ): Promise<void> {\n try {\n await sentryBuildPluginManager.createRelease();\n\n if (sourcemapsEnabled && options.sourcemaps?.disable !== 'disable-upload') {\n if (outputOptions.dir) {\n const outputDir = outputOptions.dir;\n const JS_AND_MAP_PATTERNS = [\n '/**/*.js',\n '/**/*.mjs',\n '/**/*.cjs',\n '/**/*.js.map',\n '/**/*.mjs.map',\n '/**/*.cjs.map',\n ].map(q => `${q}?(\\\\?*)?(#*)`); // We want to allow query and hash strings at the end of files\n const buildArtifacts = await globFiles(JS_AND_MAP_PATTERNS, { root: outputDir });\n await upload(buildArtifacts);\n } else if (outputOptions.file) {\n await upload([outputOptions.file]);\n } else {\n const buildArtifacts = Object.keys(bundle).map(asset => path.join(path.resolve(), asset));\n await upload(buildArtifacts);\n }\n }\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n }\n\n const name = `sentry-${buildTool}-plugin`;\n const transformHook =\n buildTool === 'vite'\n ? {\n filter: { id: JS_MODULE_ID_FILTER },\n handler: transform,\n }\n : transform;\n\n return {\n name,\n buildStart,\n ...(shouldTransform ? { transform: transformHook } : {}),\n renderChunk,\n ...(options.sourcemaps?.disable === 'disable-upload'\n ? { generateBundle: { order: 'pre' as const, handler: generateBundle } }\n : {}),\n writeBundle,\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-explicit-any\nexport function sentryRollupPlugin(userOptions: Options = {}): any {\n // We return an array here so we don't break backwards compatibility with what\n // unplugin used to return\n return [_rollupPluginInternal(userOptions, 'rollup')];\n}\n\nexport type { Options as SentryRollupPluginOptions } from '../core';\n"],"names":[],"mappings":";;;;;;;;;;;AAyCA,IAAI,wBAAA;AAEJ,MAAM,mBAAA,GAAsB,4BAAA;AAE5B,SAAS,mBAAmB,IAAA,EAAuB;AAEjD,EAAA,MAAM,iBAAA,GAAoB,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,GAAI,CAAA;AAC5C,EAAA,MAAM,eAAA,GAAkB,IAAA,CAAK,KAAA,CAAM,IAAI,CAAA;AAEvC,EAAA,IAAI,kBAAkB,QAAA,CAAS,0BAA0B,KAAK,eAAA,CAAgB,QAAA,CAA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AGO,SAAS,kBAAA,CAAmB,WAAA,GAAuB,EAAC,EAAQ;AAGjE,EAAA,OAAO,CAAC,qBAAA,CAAsB,WAAA,EAAa,QAAQ,CAAC,CAAA;AACtD;;;;"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getDebugIdSnippet, isJsFile } from '../core/index.js';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import { createRequire } from 'node:module';
|
|
5
5
|
import { randomUUID } from 'node:crypto';
|
|
6
6
|
import { createSentryBuildPluginManager } from '../core/build-plugin-manager.js';
|
|
7
7
|
import { CodeInjection, generateReleaseInjectorCode, generateModuleMetadataInjectorCode, stringToUUID } from '../core/utils.js';
|
|
8
|
+
import { createComponentNameAnnotateHooks } from '../core/component-annotate-hooks.js';
|
|
8
9
|
import { getCodeInjectionPosition } from '../core/get-code-injection-position.js';
|
|
9
10
|
import { stampDebugId, createDebugIdUploadFunction } from '../core/debug-id-upload.js';
|
|
10
11
|
|
|
@@ -88,7 +89,8 @@ function createSentryWebpackPlugin(userOptions = {}) {
|
|
|
88
89
|
}
|
|
89
90
|
const transformAnnotations = options.reactComponentAnnotation?.enabled ? createComponentNameAnnotateHooks(
|
|
90
91
|
options.reactComponentAnnotation?.ignoredComponents || [],
|
|
91
|
-
!!options.reactComponentAnnotation?._experimentalInjectIntoHtml
|
|
92
|
+
!!options.reactComponentAnnotation?._experimentalInjectIntoHtml,
|
|
93
|
+
{ logger }
|
|
92
94
|
) : void 0;
|
|
93
95
|
const transformReplace = Object.keys(replacementValues).length > 0;
|
|
94
96
|
function addCodeInjection(compiler) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/webpack/index.ts"],"sourcesContent":["/* oxlint-disable max-lines */\n\nimport type { Options } from '../core/index';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n stringToUUID,\n createComponentNameAnnotateHooks,\n CodeInjection,\n getDebugIdSnippet,\n createDebugIdUploadFunction,\n getCodeInjectionPosition,\n isJsFile,\n stampDebugId,\n} from '../core/index';\nimport * as path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { createRequire } from 'node:module';\nimport { randomUUID } from 'node:crypto';\n\nconst _req = createRequire(import.meta.url);\n\n// Resolve the loader path via the package's own exports.\n// This module may end up in a shared chunk (_chunks/) whose import.meta.url\n// does not point to the webpack/ directory where the transform file lives, so\n// a path-relative lookup would fail. Using require.resolve on the package export\n// always finds the correct installed file regardless of chunk placement.\nlet COMPONENT_ANNOTATION_LOADER: string;\ntry {\n COMPONENT_ANNOTATION_LOADER = _req.resolve('@sentry/bundler-plugins/webpack-loader');\n} catch {\n // Fallback for non-packaged environments (e.g., monorepo source runs without dist)\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore Rollup transpiles import.meta for us for CJS\n const dirname = path.dirname(fileURLToPath(import.meta.url));\n // The Rollup build emits `.js` for both CJS and ESM, so the extension is the same in both.\n COMPONENT_ANNOTATION_LOADER = path.resolve(dirname, 'component-annotation-transform.js');\n}\n\ntype PluginClass = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (options: any): unknown;\n};\n\ntype WebpackSource = {\n source: () => string | Buffer;\n};\n\ntype WebpackRawSource = {\n new (source: string): WebpackSource;\n};\n\ntype WebpackReplaceSource = WebpackSource & {\n insert: (position: number, value: string) => void;\n};\n\nconst WEBPACK_JAVASCRIPT_ASSET_REGEX = /\\.(?:js|ts|jsx|tsx|mjs|cjs|mts|cts)(?:\\?[^?]*)?(?:#[^#]*)?$/;\n\ntype WebpackAsset = {\n name: string;\n source: WebpackSource;\n info: {\n related?: {\n sourceMap?: string | string[];\n };\n };\n};\n\ntype WebpackCompiler = {\n options: {\n plugins?: unknown[];\n mode?: string;\n module?: {\n rules?: unknown[];\n };\n };\n hooks: {\n compilation: {\n tap: (name: string, callback: (compilation: WebpackCompilation) => void) => void;\n };\n thisCompilation: {\n tap: (name: string, callback: (compilation: WebpackCompilation) => void) => void;\n };\n afterEmit: {\n tapAsync: (name: string, callback: (compilation: WebpackCompilation, cb: () => void) => void) => void;\n };\n done: {\n tap: (name: string, callback: () => void) => void;\n };\n };\n webpack?: {\n DefinePlugin?: PluginClass;\n Compilation?: {\n PROCESS_ASSETS_STAGE_ADDITIONS?: number;\n PROCESS_ASSETS_STAGE_DEV_TOOLING?: number;\n };\n sources?: {\n RawSource?: WebpackRawSource;\n ReplaceSource?: new (source: WebpackSource) => WebpackReplaceSource;\n };\n };\n};\n\ntype WebpackCompilation = {\n chunks: Iterable<{\n files: Iterable<string>;\n hash?: string;\n contentHash?: { javascript?: string };\n }>;\n outputOptions: {\n path?: string;\n };\n assets: Record<string, unknown>;\n getAssets: () => WebpackAsset[];\n getAsset: (name: string) => WebpackAsset | undefined;\n updateAsset: (name: string, source: WebpackSource) => void;\n hooks: {\n processAssets: {\n tap: (\n options: { name: string; stage: number },\n callback: (assets: Record<string, WebpackSource>) => void,\n ) => void;\n };\n };\n};\n\ntype WebpackModule = {\n version?: string;\n default?: { version?: string };\n};\n\n// Only used for telemetry; `webpack` is an optional peer dependency and may be absent (e.g. rspack).\nfunction getWebpackMajorVersion(): string | undefined {\n try {\n const webpack = _req('webpack') as WebpackModule;\n const version = webpack.version ?? webpack.default?.version;\n return version?.split('.')[0];\n } catch {\n return undefined;\n }\n}\n\n/**\n * Stamps each JS asset's debug ID into the asset itself and its source map asset.\n *\n * Runs after source maps have been generated, so the JS asset no longer needs to carry\n * source map information and can be replaced with a plain `RawSource`.\n */\nfunction addDebugIdsToAssets(compilation: WebpackCompilation, RawSource: WebpackRawSource): void {\n for (const asset of compilation.getAssets()) {\n if (!isJsFile(asset.name)) {\n continue;\n }\n\n const bundleSource = asset.source.source().toString();\n const relatedSourceMap = asset.info.related?.sourceMap;\n const sourceMapName = typeof relatedSourceMap === 'string' ? relatedSourceMap : `${asset.name}.map`;\n const sourceMapAsset = compilation.getAsset(sourceMapName);\n\n const stamped = stampDebugId(bundleSource, sourceMapAsset?.source.source().toString());\n if (!stamped) {\n continue;\n }\n\n compilation.updateAsset(asset.name, new RawSource(stamped.bundleSource));\n if (stamped.sourceMapSource !== undefined) {\n compilation.updateAsset(sourceMapName, new RawSource(stamped.sourceMapSource));\n }\n }\n}\n\nfunction createSentryWebpackPlugin(userOptions: SentryWebpackPluginOptions = {}) {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? '[sentry-webpack-plugin]',\n buildTool: 'webpack',\n buildToolMajorVersion: getWebpackMajorVersion(),\n });\n\n const {\n logger,\n normalizedOptions: options,\n bundleSizeOptimizationReplacementValues: replacementValues,\n bundleMetadata,\n createDependencyOnBuildArtifacts,\n } = sentryBuildPluginManager;\n\n if (options.disable) {\n return {\n apply() {\n // noop plugin\n },\n };\n }\n\n if (process.cwd().match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n logger.warn('Running Sentry plugin from within a `node_modules` folder. Some features may not work.');\n }\n\n const sourcemapsEnabled = options.sourcemaps?.disable !== true;\n const staticInjectionCode = new CodeInjection();\n\n if (!options.release.inject) {\n logger.debug('Release injection disabled via `release.inject` option. Will not inject release.');\n } else if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not inject release. Please set the `release.name` option to identify your release.',\n );\n } else {\n staticInjectionCode.append(\n generateReleaseInjectorCode({\n release: options.release.name,\n injectBuildInformation: options._experiments.injectBuildInformation || false,\n }),\n );\n }\n\n if (Object.keys(bundleMetadata).length > 0) {\n staticInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));\n }\n\n const transformAnnotations = options.reactComponentAnnotation?.enabled\n ? createComponentNameAnnotateHooks(\n options.reactComponentAnnotation?.ignoredComponents || [],\n !!options.reactComponentAnnotation?._experimentalInjectIntoHtml,\n )\n : undefined;\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n\n function addCodeInjection(compiler: WebpackCompiler): void {\n if (staticInjectionCode.isEmpty() && !sourcemapsEnabled) {\n return;\n }\n\n const ReplaceSource = compiler.webpack?.sources?.ReplaceSource;\n const processAssetsStage = compiler.webpack?.Compilation?.PROCESS_ASSETS_STAGE_ADDITIONS;\n\n if (!ReplaceSource || processAssetsStage === undefined) {\n logger.warn(\n 'Webpack sources are not available. Skipping code injection. This usually means webpack is not properly configured.',\n );\n return;\n }\n\n compiler.hooks.compilation.tap('sentry-webpack-plugin-injection', compilation => {\n compilation.hooks.processAssets.tap(\n {\n name: 'sentry-webpack-plugin-injection',\n stage: processAssetsStage,\n },\n assets => {\n const injectedAssets = new Set<string>();\n\n for (const chunk of compilation.chunks) {\n for (const assetName of chunk.files) {\n if (injectedAssets.has(assetName) || !WEBPACK_JAVASCRIPT_ASSET_REGEX.test(assetName)) {\n continue;\n }\n\n const source = assets[assetName];\n if (!source) {\n continue;\n }\n injectedAssets.add(assetName);\n\n const sourceContents = source.source();\n const code = typeof sourceContents === 'string' ? sourceContents : Buffer.from(sourceContents).toString();\n const codeToInject = staticInjectionCode.clone();\n if (sourcemapsEnabled) {\n const hash = chunk.contentHash?.javascript ?? chunk.hash;\n codeToInject.append(getDebugIdSnippet(hash ? stringToUUID(hash) : randomUUID()));\n }\n\n const injectionPosition = getCodeInjectionPosition(code);\n const injection = injectionPosition === code.length ? `\\n${codeToInject.code()}` : codeToInject.code();\n const updatedSource = new ReplaceSource(source);\n updatedSource.insert(injectionPosition, injection);\n compilation.updateAsset(assetName, updatedSource);\n }\n }\n },\n );\n });\n }\n\n return {\n apply(compiler: WebpackCompiler) {\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n\n const { DefinePlugin } = compiler.webpack ?? {};\n\n // BannerPlugin prepends executable code before directive prologues.\n addCodeInjection(compiler);\n\n // The upload routine (which stamps debug IDs into temp copies of the artifacts) is skipped\n // with `disable-upload`, so the emitted artifacts get stamped in the asset pipeline instead.\n if (sourcemapsEnabled && options.sourcemaps?.disable === 'disable-upload') {\n const RawSource = compiler.webpack?.sources?.RawSource;\n // Right after source map generation (and thus after minification, which would strip the comment),\n // so later stages (real content hashing, subresource integrity) see the final assets.\n const stage = (compiler.webpack?.Compilation?.PROCESS_ASSETS_STAGE_DEV_TOOLING ?? 500) + 1;\n\n if (!RawSource) {\n logger.warn(\n 'Webpack sources are not available. Skipping debug ID injection into emitted source maps. This usually means webpack is not properly configured.',\n );\n } else {\n compiler.hooks.thisCompilation.tap('sentry-webpack-plugin', compilation => {\n compilation.hooks.processAssets.tap({ name: 'sentry-webpack-plugin', stage }, () => {\n addDebugIdsToAssets(compilation, RawSource);\n });\n });\n }\n }\n\n // Add DefinePlugin for bundle size optimizations\n if (transformReplace && DefinePlugin) {\n compiler.options.plugins = compiler.options.plugins || [];\n compiler.options.plugins.push(new DefinePlugin(replacementValues));\n }\n\n // Add component name annotation transform\n if (transformAnnotations?.transform) {\n compiler.options.module = compiler.options.module || {};\n compiler.options.module.rules = compiler.options.module.rules || [];\n compiler.options.module.rules.unshift({\n test: /\\.[jt]sx$/,\n exclude: /node_modules/,\n enforce: 'pre',\n use: [\n {\n loader: COMPONENT_ANNOTATION_LOADER,\n options: {\n transform: transformAnnotations.transform,\n },\n },\n ],\n });\n }\n\n compiler.hooks.afterEmit.tapAsync(\n 'sentry-webpack-plugin',\n (compilation: WebpackCompilation, callback: (err?: Error) => void) => {\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n\n const run = async (): Promise<void> => {\n try {\n await sentryBuildPluginManager.createRelease();\n if (sourcemapsEnabled && options.sourcemaps?.disable !== 'disable-upload') {\n const outputPath = compilation.outputOptions.path ?? path.resolve();\n const buildArtifacts = Object.keys(compilation.assets).map(asset => path.join(outputPath, asset));\n await upload(buildArtifacts);\n }\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n };\n\n run().then(\n () => callback(),\n (err: Error) => callback(err),\n );\n },\n );\n\n if (userOptions._experiments?.forceExitOnBuildCompletion && compiler.options.mode === 'production') {\n compiler.hooks.done.tap('sentry-webpack-plugin', () => {\n setTimeout(() => {\n logger.debug('Exiting process after debug file upload');\n process.exit(0);\n });\n });\n }\n },\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const sentryWebpackPlugin: (options?: SentryWebpackPluginOptions) => any = createSentryWebpackPlugin;\n\nexport type SentryWebpackPluginOptions = Options & {\n _experiments?: Options['_experiments'] & {\n /**\n * If enabled, the webpack plugin will exit the build process after the build completes.\n * Use this with caution, as it will terminate the process.\n *\n * More information: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/345\n *\n * @default false\n */\n forceExitOnBuildCompletion?: boolean;\n };\n};\n"],"names":[],"mappings":";;;;;;;;;;AAqBA,MAAM,IAAA,GAAO,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AAO1C,IAAI,2BAAA;AACJ,IAAI;AACF,EAAA,2BAAA,GAA8B,IAAA,CAAK,QAAQ,wCAAwC,CAAA;AACrF,CAAA,CAAA,MAAQ;AAIN,EAAA,MAAM,UAAU,IAAA,CAAK,OAAA,CAAQ,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAC,CAAA;AAE3D,EAAA,2BAAA,GAA8B,IAAA,CAAK,OAAA,CAAQ,OAAA,EAAS,mCAAmC,CAAA;AACzF;AAmBA,MAAM,8BAAA,GAAiC,6DAAA;AA4EvC,SAAS,sBAAA,GAA6C;AACpD,EAAA,IAAI;AACF,IAAA,MAAM,OAAA,GAAU,KAAK,SAAS,CAAA;AAC9B,IAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,OAAA,IAAW,OAAA,CAAQ,OAAA,EAAS,OAAA;AACpD,IAAA,OAAO,OAAA,EAAS,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,CAA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,CAAC,GAAA,KAAe,QAAA,CAAS,GAAG;AAAA,WAC9B;AAAA,QACF;AAAA,OACF;AAEA,MAAA,IAAI,YAAY,YAAA,EAAc,0BAAA,IAA8B,QAAA,CAAS,OAAA,CAAQ,SAAS,YAAA,EAAc;AAClG,QAAA,QAAA,CAAS,KAAA,CAAM,IAAA,CAAK,GAAA,CAAI,uBAAA,EAAyB,MAAM;AACrD,UAAA,UAAA,CAAW,MAAM;AACf,YAAA,MAAA,CAAO,MAAM,yCAAyC,CAAA;AACtD,YAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,UAChB,CAAC,CAAA;AAAA,QACH,CAAC,CAAA;AAAA,MACH;AAAA,IACF;AAAA,GACF;AACF;AAGO,MAAM,mBAAA,GAAqE;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/webpack/index.ts"],"sourcesContent":["/* oxlint-disable max-lines */\n\nimport type { Options } from '../core/index';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n stringToUUID,\n createComponentNameAnnotateHooks,\n CodeInjection,\n getDebugIdSnippet,\n createDebugIdUploadFunction,\n getCodeInjectionPosition,\n isJsFile,\n stampDebugId,\n} from '../core/index';\nimport * as path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { createRequire } from 'node:module';\nimport { randomUUID } from 'node:crypto';\n\nconst _req = createRequire(import.meta.url);\n\n// Resolve the loader path via the package's own exports.\n// This module may end up in a shared chunk (_chunks/) whose import.meta.url\n// does not point to the webpack/ directory where the transform file lives, so\n// a path-relative lookup would fail. Using require.resolve on the package export\n// always finds the correct installed file regardless of chunk placement.\nlet COMPONENT_ANNOTATION_LOADER: string;\ntry {\n COMPONENT_ANNOTATION_LOADER = _req.resolve('@sentry/bundler-plugins/webpack-loader');\n} catch {\n // Fallback for non-packaged environments (e.g., monorepo source runs without dist)\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore Rollup transpiles import.meta for us for CJS\n const dirname = path.dirname(fileURLToPath(import.meta.url));\n // The Rollup build emits `.js` for both CJS and ESM, so the extension is the same in both.\n COMPONENT_ANNOTATION_LOADER = path.resolve(dirname, 'component-annotation-transform.js');\n}\n\ntype PluginClass = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (options: any): unknown;\n};\n\ntype WebpackSource = {\n source: () => string | Buffer;\n};\n\ntype WebpackRawSource = {\n new (source: string): WebpackSource;\n};\n\ntype WebpackReplaceSource = WebpackSource & {\n insert: (position: number, value: string) => void;\n};\n\nconst WEBPACK_JAVASCRIPT_ASSET_REGEX = /\\.(?:js|ts|jsx|tsx|mjs|cjs|mts|cts)(?:\\?[^?]*)?(?:#[^#]*)?$/;\n\ntype WebpackAsset = {\n name: string;\n source: WebpackSource;\n info: {\n related?: {\n sourceMap?: string | string[];\n };\n };\n};\n\ntype WebpackCompiler = {\n options: {\n plugins?: unknown[];\n mode?: string;\n module?: {\n rules?: unknown[];\n };\n };\n hooks: {\n compilation: {\n tap: (name: string, callback: (compilation: WebpackCompilation) => void) => void;\n };\n thisCompilation: {\n tap: (name: string, callback: (compilation: WebpackCompilation) => void) => void;\n };\n afterEmit: {\n tapAsync: (name: string, callback: (compilation: WebpackCompilation, cb: () => void) => void) => void;\n };\n done: {\n tap: (name: string, callback: () => void) => void;\n };\n };\n webpack?: {\n DefinePlugin?: PluginClass;\n Compilation?: {\n PROCESS_ASSETS_STAGE_ADDITIONS?: number;\n PROCESS_ASSETS_STAGE_DEV_TOOLING?: number;\n };\n sources?: {\n RawSource?: WebpackRawSource;\n ReplaceSource?: new (source: WebpackSource) => WebpackReplaceSource;\n };\n };\n};\n\ntype WebpackCompilation = {\n chunks: Iterable<{\n files: Iterable<string>;\n hash?: string;\n contentHash?: { javascript?: string };\n }>;\n outputOptions: {\n path?: string;\n };\n assets: Record<string, unknown>;\n getAssets: () => WebpackAsset[];\n getAsset: (name: string) => WebpackAsset | undefined;\n updateAsset: (name: string, source: WebpackSource) => void;\n hooks: {\n processAssets: {\n tap: (\n options: { name: string; stage: number },\n callback: (assets: Record<string, WebpackSource>) => void,\n ) => void;\n };\n };\n};\n\ntype WebpackModule = {\n version?: string;\n default?: { version?: string };\n};\n\n// Only used for telemetry; `webpack` is an optional peer dependency and may be absent (e.g. rspack).\nfunction getWebpackMajorVersion(): string | undefined {\n try {\n const webpack = _req('webpack') as WebpackModule;\n const version = webpack.version ?? webpack.default?.version;\n return version?.split('.')[0];\n } catch {\n return undefined;\n }\n}\n\n/**\n * Stamps each JS asset's debug ID into the asset itself and its source map asset.\n *\n * Runs after source maps have been generated, so the JS asset no longer needs to carry\n * source map information and can be replaced with a plain `RawSource`.\n */\nfunction addDebugIdsToAssets(compilation: WebpackCompilation, RawSource: WebpackRawSource): void {\n for (const asset of compilation.getAssets()) {\n if (!isJsFile(asset.name)) {\n continue;\n }\n\n const bundleSource = asset.source.source().toString();\n const relatedSourceMap = asset.info.related?.sourceMap;\n const sourceMapName = typeof relatedSourceMap === 'string' ? relatedSourceMap : `${asset.name}.map`;\n const sourceMapAsset = compilation.getAsset(sourceMapName);\n\n const stamped = stampDebugId(bundleSource, sourceMapAsset?.source.source().toString());\n if (!stamped) {\n continue;\n }\n\n compilation.updateAsset(asset.name, new RawSource(stamped.bundleSource));\n if (stamped.sourceMapSource !== undefined) {\n compilation.updateAsset(sourceMapName, new RawSource(stamped.sourceMapSource));\n }\n }\n}\n\nfunction createSentryWebpackPlugin(userOptions: SentryWebpackPluginOptions = {}) {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? '[sentry-webpack-plugin]',\n buildTool: 'webpack',\n buildToolMajorVersion: getWebpackMajorVersion(),\n });\n\n const {\n logger,\n normalizedOptions: options,\n bundleSizeOptimizationReplacementValues: replacementValues,\n bundleMetadata,\n createDependencyOnBuildArtifacts,\n } = sentryBuildPluginManager;\n\n if (options.disable) {\n return {\n apply() {\n // noop plugin\n },\n };\n }\n\n if (process.cwd().match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n logger.warn('Running Sentry plugin from within a `node_modules` folder. Some features may not work.');\n }\n\n const sourcemapsEnabled = options.sourcemaps?.disable !== true;\n const staticInjectionCode = new CodeInjection();\n\n if (!options.release.inject) {\n logger.debug('Release injection disabled via `release.inject` option. Will not inject release.');\n } else if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not inject release. Please set the `release.name` option to identify your release.',\n );\n } else {\n staticInjectionCode.append(\n generateReleaseInjectorCode({\n release: options.release.name,\n injectBuildInformation: options._experiments.injectBuildInformation || false,\n }),\n );\n }\n\n if (Object.keys(bundleMetadata).length > 0) {\n staticInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));\n }\n\n const transformAnnotations = options.reactComponentAnnotation?.enabled\n ? createComponentNameAnnotateHooks(\n options.reactComponentAnnotation?.ignoredComponents || [],\n !!options.reactComponentAnnotation?._experimentalInjectIntoHtml,\n { logger },\n )\n : undefined;\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n\n function addCodeInjection(compiler: WebpackCompiler): void {\n if (staticInjectionCode.isEmpty() && !sourcemapsEnabled) {\n return;\n }\n\n const ReplaceSource = compiler.webpack?.sources?.ReplaceSource;\n const processAssetsStage = compiler.webpack?.Compilation?.PROCESS_ASSETS_STAGE_ADDITIONS;\n\n if (!ReplaceSource || processAssetsStage === undefined) {\n logger.warn(\n 'Webpack sources are not available. Skipping code injection. This usually means webpack is not properly configured.',\n );\n return;\n }\n\n compiler.hooks.compilation.tap('sentry-webpack-plugin-injection', compilation => {\n compilation.hooks.processAssets.tap(\n {\n name: 'sentry-webpack-plugin-injection',\n stage: processAssetsStage,\n },\n assets => {\n const injectedAssets = new Set<string>();\n\n for (const chunk of compilation.chunks) {\n for (const assetName of chunk.files) {\n if (injectedAssets.has(assetName) || !WEBPACK_JAVASCRIPT_ASSET_REGEX.test(assetName)) {\n continue;\n }\n\n const source = assets[assetName];\n if (!source) {\n continue;\n }\n injectedAssets.add(assetName);\n\n const sourceContents = source.source();\n const code = typeof sourceContents === 'string' ? sourceContents : Buffer.from(sourceContents).toString();\n const codeToInject = staticInjectionCode.clone();\n if (sourcemapsEnabled) {\n const hash = chunk.contentHash?.javascript ?? chunk.hash;\n codeToInject.append(getDebugIdSnippet(hash ? stringToUUID(hash) : randomUUID()));\n }\n\n const injectionPosition = getCodeInjectionPosition(code);\n const injection = injectionPosition === code.length ? `\\n${codeToInject.code()}` : codeToInject.code();\n const updatedSource = new ReplaceSource(source);\n updatedSource.insert(injectionPosition, injection);\n compilation.updateAsset(assetName, updatedSource);\n }\n }\n },\n );\n });\n }\n\n return {\n apply(compiler: WebpackCompiler) {\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n\n const { DefinePlugin } = compiler.webpack ?? {};\n\n // BannerPlugin prepends executable code before directive prologues.\n addCodeInjection(compiler);\n\n // The upload routine (which stamps debug IDs into temp copies of the artifacts) is skipped\n // with `disable-upload`, so the emitted artifacts get stamped in the asset pipeline instead.\n if (sourcemapsEnabled && options.sourcemaps?.disable === 'disable-upload') {\n const RawSource = compiler.webpack?.sources?.RawSource;\n // Right after source map generation (and thus after minification, which would strip the comment),\n // so later stages (real content hashing, subresource integrity) see the final assets.\n const stage = (compiler.webpack?.Compilation?.PROCESS_ASSETS_STAGE_DEV_TOOLING ?? 500) + 1;\n\n if (!RawSource) {\n logger.warn(\n 'Webpack sources are not available. Skipping debug ID injection into emitted source maps. This usually means webpack is not properly configured.',\n );\n } else {\n compiler.hooks.thisCompilation.tap('sentry-webpack-plugin', compilation => {\n compilation.hooks.processAssets.tap({ name: 'sentry-webpack-plugin', stage }, () => {\n addDebugIdsToAssets(compilation, RawSource);\n });\n });\n }\n }\n\n // Add DefinePlugin for bundle size optimizations\n if (transformReplace && DefinePlugin) {\n compiler.options.plugins = compiler.options.plugins || [];\n compiler.options.plugins.push(new DefinePlugin(replacementValues));\n }\n\n // Add component name annotation transform\n if (transformAnnotations?.transform) {\n compiler.options.module = compiler.options.module || {};\n compiler.options.module.rules = compiler.options.module.rules || [];\n compiler.options.module.rules.unshift({\n test: /\\.[jt]sx$/,\n exclude: /node_modules/,\n enforce: 'pre',\n use: [\n {\n loader: COMPONENT_ANNOTATION_LOADER,\n options: {\n transform: transformAnnotations.transform,\n },\n },\n ],\n });\n }\n\n compiler.hooks.afterEmit.tapAsync(\n 'sentry-webpack-plugin',\n (compilation: WebpackCompilation, callback: (err?: Error) => void) => {\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n\n const run = async (): Promise<void> => {\n try {\n await sentryBuildPluginManager.createRelease();\n if (sourcemapsEnabled && options.sourcemaps?.disable !== 'disable-upload') {\n const outputPath = compilation.outputOptions.path ?? path.resolve();\n const buildArtifacts = Object.keys(compilation.assets).map(asset => path.join(outputPath, asset));\n await upload(buildArtifacts);\n }\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n };\n\n run().then(\n () => callback(),\n (err: Error) => callback(err),\n );\n },\n );\n\n if (userOptions._experiments?.forceExitOnBuildCompletion && compiler.options.mode === 'production') {\n compiler.hooks.done.tap('sentry-webpack-plugin', () => {\n setTimeout(() => {\n logger.debug('Exiting process after debug file upload');\n process.exit(0);\n });\n });\n }\n },\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const sentryWebpackPlugin: (options?: SentryWebpackPluginOptions) => any = createSentryWebpackPlugin;\n\nexport type SentryWebpackPluginOptions = Options & {\n _experiments?: Options['_experiments'] & {\n /**\n * If enabled, the webpack plugin will exit the build process after the build completes.\n * Use this with caution, as it will terminate the process.\n *\n * More information: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/345\n *\n * @default false\n */\n forceExitOnBuildCompletion?: boolean;\n };\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAq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ta, ParseAstAsync } from './component-annotation-oxc-ast';
|
|
2
|
+
import type { Logger } from './logger';
|
|
3
|
+
export declare function createComponentNameAnnotateHooks(ignoredComponents: string[], injectIntoHtml: boolean, options?: {
|
|
4
|
+
getParseAstAsync?: () => Promise<ParseAstAsync | null>;
|
|
5
|
+
logger?: Logger;
|
|
6
|
+
}): {
|
|
7
|
+
transform(this: void, code: string, id: string, meta?: ComponentAnnotationTransformMeta): Promise<import("./component-annotation-oxc-ast").ComponentAnnotationTransformResult>;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=component-annotate-hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-annotate-hooks.d.ts","sourceRoot":"","sources":["../../../src/core/component-annotate-hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gCAAgC,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACtG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAUvC,wBAAgB,gCAAgC,CAC9C,iBAAiB,EAAE,MAAM,EAAE,EAC3B,cAAc,EAAE,OAAO,EACvB,OAAO,GAAE;IAAE,gBAAgB,CAAC,EAAE,MAAM,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO;IAuBvF,SAAS,OAAO,IAAI,QAAQ,MAAM,MAAM,MAAM,SAAS,gCAAgC;EAI1F"}
|
|
@@ -51,7 +51,7 @@ export type ComponentAnnotationTransformMeta = {
|
|
|
51
51
|
export type ComponentAnnotationTransformResult = {
|
|
52
52
|
code: string;
|
|
53
53
|
map?: SourceMap | string;
|
|
54
|
-
} | null
|
|
54
|
+
} | null;
|
|
55
55
|
export declare function isAstNode(value: unknown): value is AstNode;
|
|
56
56
|
export declare function walkAst(node: unknown, visit: (node: AstNode) => void): void;
|
|
57
57
|
//# sourceMappingURL=component-annotation-oxc-ast.d.ts.map
|
|
@@ -1 +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CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;KAC9B,GAAG,SAAS,GAAG,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;CAC1B,GAAG,IAAI,CAAC;AAET,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE1D;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI,CAgB3E"}
|
|
@@ -11,6 +11,11 @@ export declare function getJSXName(name: unknown): string;
|
|
|
11
11
|
export declare function getInsertionOffset(code: string, openingElement: JSXOpeningElementNode): number | null;
|
|
12
12
|
export declare function isReactFragment(openingElement: JSXOpeningElementNode, fragmentContext: FragmentContext): boolean;
|
|
13
13
|
export declare function addPendingAttributes(code: string, openingElement: JSXOpeningElementNode, componentName: string, ignoredComponents: string[], fragmentContext: FragmentContext, sourceFileName: string, insertionsByOffset: Map<number, PendingInsertion>): void;
|
|
14
|
+
/**
|
|
15
|
+
* Returns `true` when the element is an HTML element, because HTML mode only
|
|
16
|
+
* annotates the first HTML elements below a component root.
|
|
17
|
+
*/
|
|
18
|
+
export declare function addPendingHtmlAttribute(code: string, openingElement: JSXOpeningElementNode, componentName: string, ignoredComponents: string[], fragmentContext: FragmentContext, insertionsByOffset: Map<number, PendingInsertion>): boolean;
|
|
14
19
|
export declare function toAttributeInsertions(insertionsByOffset: Map<number, PendingInsertion>): AttributeInsertion[];
|
|
15
20
|
export {};
|
|
16
21
|
//# sourceMappingURL=component-annotation-oxc-jsx.d.ts.map
|