@sentry/bundler-plugins 11.11.0 → 11.12.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/build/cjs/core/build-plugin-manager.js +27 -8
- package/build/cjs/core/build-plugin-manager.js.map +1 -1
- package/build/cjs/core/index.js.map +1 -1
- package/build/cjs/core/upload-filter.js +57 -0
- package/build/cjs/core/upload-filter.js.map +1 -0
- package/build/cjs/core/version.js +1 -1
- package/build/cjs/core/version.js.map +1 -1
- package/build/cjs/esbuild/index.js +1 -0
- package/build/cjs/esbuild/index.js.map +1 -1
- package/build/cjs/rollup/index.js +49 -9
- package/build/cjs/rollup/index.js.map +1 -1
- package/build/cjs/rollup/source-map-handling.js +202 -0
- package/build/cjs/rollup/source-map-handling.js.map +1 -0
- package/build/cjs/vite/index.js +4 -18
- package/build/cjs/vite/index.js.map +1 -1
- package/build/cjs/vite/source-map-hooks.js +93 -0
- package/build/cjs/vite/source-map-hooks.js.map +1 -0
- package/build/cjs/webpack/index.js +113 -1
- package/build/cjs/webpack/index.js.map +1 -1
- package/build/esm/core/build-plugin-manager.js +27 -8
- package/build/esm/core/build-plugin-manager.js.map +1 -1
- package/build/esm/core/index.js.map +1 -1
- package/build/esm/core/upload-filter.js +41 -0
- package/build/esm/core/upload-filter.js.map +1 -0
- package/build/esm/core/version.js +1 -1
- package/build/esm/core/version.js.map +1 -1
- package/build/esm/esbuild/index.js +1 -0
- package/build/esm/esbuild/index.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/rollup/index.js +49 -10
- package/build/esm/rollup/index.js.map +1 -1
- package/build/esm/rollup/source-map-handling.js +183 -0
- package/build/esm/rollup/source-map-handling.js.map +1 -0
- package/build/esm/vite/index.js +5 -19
- package/build/esm/vite/index.js.map +1 -1
- package/build/esm/vite/source-map-hooks.js +77 -0
- package/build/esm/vite/source-map-hooks.js.map +1 -0
- package/build/esm/webpack/index.js +114 -2
- package/build/esm/webpack/index.js.map +1 -1
- package/build/types/core/build-plugin-manager.d.ts +17 -5
- package/build/types/core/build-plugin-manager.d.ts.map +1 -1
- package/build/types/core/index.d.ts +1 -0
- package/build/types/core/index.d.ts.map +1 -1
- package/build/types/core/types.d.ts +7 -0
- package/build/types/core/types.d.ts.map +1 -1
- package/build/types/core/upload-filter.d.ts +9 -0
- package/build/types/core/upload-filter.d.ts.map +1 -0
- package/build/types/core/version.d.ts +1 -1
- package/build/types/esbuild/index.d.ts.map +1 -1
- package/build/types/rollup/index.d.ts +106 -6
- package/build/types/rollup/index.d.ts.map +1 -1
- package/build/types/rollup/source-map-handling.d.ts +59 -0
- package/build/types/rollup/source-map-handling.d.ts.map +1 -0
- package/build/types/vite/index.d.ts +1 -5
- package/build/types/vite/index.d.ts.map +1 -1
- package/build/types/vite/source-map-hooks.d.ts +45 -0
- package/build/types/vite/source-map-hooks.d.ts.map +1 -0
- package/build/types/webpack/index.d.ts.map +1 -1
- package/package.json +40 -38
|
@@ -4,6 +4,8 @@ import * as path from 'node:path';
|
|
|
4
4
|
import { createRequire } from 'node:module';
|
|
5
5
|
import { finalizeRolldownDebugIds, hasExistingDebugID, getDebugIdForChunk } from './debug-id-injection.js';
|
|
6
6
|
import { stampDebugIds } from './debug-id-stamping.js';
|
|
7
|
+
import { createSourceMapHandling } from './source-map-handling.js';
|
|
8
|
+
import { createViteSourceMapHooks } from '../vite/source-map-hooks.js';
|
|
7
9
|
import { createSentryBuildPluginManager } from '../core/build-plugin-manager.js';
|
|
8
10
|
import { CodeInjection, generateReleaseInjectorCode, generateModuleMetadataInjectorCode, replaceBooleanFlagsInCode } from '../core/utils.js';
|
|
9
11
|
import { createComponentNameAnnotateHooks } from '../core/component-annotate-hooks.js';
|
|
@@ -39,7 +41,7 @@ function getViteParseAstAsync() {
|
|
|
39
41
|
}
|
|
40
42
|
return viteParseAstAsyncPromise;
|
|
41
43
|
}
|
|
42
|
-
function
|
|
44
|
+
function _createRollupPluginInternals(userOptions = {}, buildTool, buildToolMajorVersion) {
|
|
43
45
|
const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {
|
|
44
46
|
loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[sentry-${buildTool}-plugin]`,
|
|
45
47
|
buildTool,
|
|
@@ -54,7 +56,10 @@ function _rollupPluginInternal(userOptions = {}, buildTool, buildToolMajorVersio
|
|
|
54
56
|
} = sentryBuildPluginManager;
|
|
55
57
|
if (options.disable) {
|
|
56
58
|
return {
|
|
57
|
-
|
|
59
|
+
main: {
|
|
60
|
+
name: "sentry-noop-plugin"
|
|
61
|
+
},
|
|
62
|
+
post: void 0
|
|
58
63
|
};
|
|
59
64
|
}
|
|
60
65
|
if (process.cwd().match(/\\node_modules\\|\/node_modules\//)) {
|
|
@@ -63,6 +68,7 @@ function _rollupPluginInternal(userOptions = {}, buildTool, buildToolMajorVersio
|
|
|
63
68
|
const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
|
|
64
69
|
const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });
|
|
65
70
|
const sourcemapsEnabled = options.sourcemaps?.disable !== true;
|
|
71
|
+
const sourceMapHandling = createSourceMapHandling(sentryBuildPluginManager);
|
|
66
72
|
const releaseInjectionCode = new CodeInjection();
|
|
67
73
|
const chunkInjectionCode = new CodeInjection();
|
|
68
74
|
if (!options.release.inject) {
|
|
@@ -151,9 +157,12 @@ ${injectCode.code()}` : injectCode.code();
|
|
|
151
157
|
stampDebugIds(bundle, true);
|
|
152
158
|
}
|
|
153
159
|
async function writeBundle(outputOptions, bundle) {
|
|
160
|
+
const staging = await sourceMapHandling.takeStaging(outputOptions, bundle);
|
|
161
|
+
let stagingHandedOver = false;
|
|
154
162
|
try {
|
|
155
163
|
await sentryBuildPluginManager.createRelease();
|
|
156
164
|
if (sourcemapsEnabled && options.sourcemaps?.disable !== "disable-upload") {
|
|
165
|
+
let buildArtifacts;
|
|
157
166
|
if (outputOptions.dir) {
|
|
158
167
|
const outputDir = outputOptions.dir;
|
|
159
168
|
const JS_AND_MAP_PATTERNS = [
|
|
@@ -164,15 +173,23 @@ ${injectCode.code()}` : injectCode.code();
|
|
|
164
173
|
"/**/*.mjs.map",
|
|
165
174
|
"/**/*.cjs.map"
|
|
166
175
|
].map((q) => `${q}?(\\?*)?(#*)`);
|
|
167
|
-
|
|
168
|
-
await upload(buildArtifacts);
|
|
176
|
+
buildArtifacts = await globFiles(JS_AND_MAP_PATTERNS, { root: outputDir });
|
|
169
177
|
} else if (outputOptions.file) {
|
|
170
|
-
|
|
178
|
+
buildArtifacts = [outputOptions.file];
|
|
171
179
|
} else {
|
|
172
|
-
|
|
173
|
-
await upload(buildArtifacts);
|
|
180
|
+
buildArtifacts = Object.keys(bundle ?? {}).map((asset) => path.join(path.resolve(), asset));
|
|
174
181
|
}
|
|
182
|
+
stagingHandedOver = true;
|
|
183
|
+
await upload(buildArtifacts, { staging });
|
|
184
|
+
} else {
|
|
185
|
+
stagingHandedOver = true;
|
|
186
|
+
await staging?.discard();
|
|
187
|
+
}
|
|
188
|
+
} catch (e) {
|
|
189
|
+
if (!stagingHandedOver) {
|
|
190
|
+
await staging?.keep("The source map upload did not run.");
|
|
175
191
|
}
|
|
192
|
+
throw e;
|
|
176
193
|
} finally {
|
|
177
194
|
freeGlobalDependencyOnBuildArtifacts();
|
|
178
195
|
await sentryBuildPluginManager.deleteArtifacts();
|
|
@@ -183,18 +200,40 @@ ${injectCode.code()}` : injectCode.code();
|
|
|
183
200
|
filter: { id: JS_MODULE_ID_FILTER },
|
|
184
201
|
handler: transform
|
|
185
202
|
} : transform;
|
|
186
|
-
|
|
203
|
+
const viteSourceMapHooks = buildTool === "vite" ? createViteSourceMapHooks(sentryBuildPluginManager, sourceMapHandling) : void 0;
|
|
204
|
+
const main = {
|
|
187
205
|
name,
|
|
188
206
|
buildStart,
|
|
189
207
|
...shouldTransform ? { transform: transformHook } : {},
|
|
208
|
+
...viteSourceMapHooks ? { configResolved: viteSourceMapHooks.configResolved } : { outputOptions: sourceMapHandling.outputOptions },
|
|
190
209
|
renderChunk,
|
|
191
210
|
generateBundle: { order: "pre", handler: generateBundle },
|
|
192
211
|
writeBundle
|
|
193
212
|
};
|
|
213
|
+
const post = {
|
|
214
|
+
name: buildTool === "vite" ? "sentry-vite-upload-staging" : "sentry-rollup-upload-staging",
|
|
215
|
+
// On the post plugin, so framework plugins that set `build.sourcemap`
|
|
216
|
+
// themselves run first and the decision sees the merged setting.
|
|
217
|
+
...viteSourceMapHooks ? { config: viteSourceMapHooks.config } : {},
|
|
218
|
+
generateBundle: {
|
|
219
|
+
order: "post",
|
|
220
|
+
async handler(outputOptions, bundle, isWrite) {
|
|
221
|
+
if (buildTool === "vite" && options.sourcemaps?.disable === "disable-upload") {
|
|
222
|
+
stampDebugIds(bundle, false);
|
|
223
|
+
}
|
|
224
|
+
await sourceMapHandling.stageSourceMaps(outputOptions, bundle, isWrite);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
return { main, post };
|
|
229
|
+
}
|
|
230
|
+
function _rollupPluginInternal(userOptions = {}, buildTool, buildToolMajorVersion) {
|
|
231
|
+
return _createRollupPluginInternals(userOptions, buildTool, buildToolMajorVersion).main;
|
|
194
232
|
}
|
|
195
233
|
function sentryRollupPlugin(userOptions = {}) {
|
|
196
|
-
|
|
234
|
+
const { main, post } = _createRollupPluginInternals(userOptions, "rollup");
|
|
235
|
+
return post ? [main, post] : [main];
|
|
197
236
|
}
|
|
198
237
|
|
|
199
|
-
export { _rollupPluginInternal, sentryRollupPlugin };
|
|
238
|
+
export { _createRollupPluginInternals, _rollupPluginInternal, sentryRollupPlugin };
|
|
200
239
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/rollup/index.ts"],"sourcesContent":["import type { ChunkGraphNode, Options } from '../core';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n isJsFile,\n isInitialChunk,\n shouldSkipCodeInjection,\n getDebugIdSnippet,\n createDebugIdUploadFunction,\n globFiles,\n createComponentNameAnnotateHooks,\n replaceBooleanFlagsInCode,\n CodeInjection,\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';\nimport { finalizeRolldownDebugIds, getDebugIdForChunk, hasExistingDebugID } from './debug-id-injection';\nimport { stampDebugIds, type OutputBundle } from './debug-id-stamping';\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\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\n// Rolldown sets `meta.rolldownVersion` on the plugin context.\ntype PluginContext = { meta?: { rolldownVersion?: string } };\n\nconst JS_MODULE_ID_FILTER = /\\.[cm]?[jt]sx?(?:[?#].*)?$/;\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 releaseInjectionCode = new CodeInjection();\n const chunkInjectionCode = 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 releaseInjectionCode.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 chunkInjectionCode.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 this: PluginContext | undefined,\n code: string,\n chunk: { fileName: string; facadeModuleId?: string | null; isEntry?: boolean },\n _?: unknown,\n meta?: { magicString?: MagicString; chunks?: Record<string, ChunkGraphNode> },\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 = new CodeInjection();\n\n if (isInitialChunk(chunk, meta?.chunks)) {\n injectCode.append(releaseInjectionCode);\n }\n\n injectCode.append(chunkInjectionCode);\n\n if (sourcemapsEnabled && !hasExistingDebugID(code)) {\n const debugId = getDebugIdForChunk(code, !!this?.meta?.rolldownVersion);\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 * Resolves Rolldown's placeholder debug IDs, then stamps debug IDs into the emitted chunks and\n * 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(this: PluginContext | undefined, _outputOptions: unknown, bundle: OutputBundle): void {\n if (this?.meta?.rolldownVersion) {\n finalizeRolldownDebugIds(bundle);\n }\n\n if (options.sourcemaps?.disable !== 'disable-upload') {\n return;\n }\n\n stampDebugIds(bundle, true);\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 generateBundle: { order: 'pre' as const, handler: generateBundle },\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":";;;;;;;;;;;;;AAmCA,IAAI,wBAAA;AAKJ,MAAM,mBAAA,GAAsB,4BAAA;AAE5B,SAAS,qBAAA,GAA4C;AACnD,EAAA,IAAI;AAGF,IAAA,MAAM,GAAA,GAAM,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AACzC,IAAA,MAAM,MAAA,GAAS,IAAI,QAAQ,CAAA;AAC3B,IAAA,OAAO,MAAA,CAAO,OAAA,EAAS,KAAA,CAAM,GAAG,EAAE,CAAC,CAAA;AAAA,EACrC,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,oBAAA,GAA0D;AACjE,EAAA,IAAI,CAAC,wBAAA,EAA0B;AAC7B,IAAA,wBAAA,GAA2B,OAAA,CAAQ,OAAA,EAAQ,CACxC,IAAA,CAAK,YAAY;AAGhB,MAAA,MAAM,UAAA,GAAa,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,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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,cAAA,EAAgB,EAAE,KAAA,EAAO,KAAA,EAAgB,SAAS,cAAA,EAAe;AAAA,IACjE;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 { ChunkGraphNode, Options } from '../core';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n isJsFile,\n isInitialChunk,\n shouldSkipCodeInjection,\n getDebugIdSnippet,\n createDebugIdUploadFunction,\n globFiles,\n createComponentNameAnnotateHooks,\n replaceBooleanFlagsInCode,\n CodeInjection,\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';\nimport { finalizeRolldownDebugIds, getDebugIdForChunk, hasExistingDebugID } from './debug-id-injection';\nimport { stampDebugIds, type OutputBundle } from './debug-id-stamping';\nimport { createSourceMapHandling, type OutputDestinationOptions } from './source-map-handling';\nimport { createViteSourceMapHooks } from '../vite/source-map-hooks';\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\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\n// Rolldown sets `meta.rolldownVersion` on the plugin context.\ntype PluginContext = { meta?: { rolldownVersion?: string } };\n\nconst JS_MODULE_ID_FILTER = /\\.[cm]?[jt]sx?(?:[?#].*)?$/;\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 - internal plugin factory shared by the Rollup and Vite plugins.\n *\n * `main` carries injection, release creation and the upload. `post` runs last in `generateBundle`,\n * copies chunks and their source maps into the upload staging folder and drops the map assets\n * from the bundle, so the bundler never writes them.\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function _createRollupPluginInternals(\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 main: {\n name: 'sentry-noop-plugin',\n },\n post: undefined,\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 sourceMapHandling = createSourceMapHandling(sentryBuildPluginManager);\n const releaseInjectionCode = new CodeInjection();\n const chunkInjectionCode = 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 releaseInjectionCode.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 chunkInjectionCode.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 this: PluginContext | undefined,\n code: string,\n chunk: { fileName: string; facadeModuleId?: string | null; isEntry?: boolean },\n _?: unknown,\n meta?: { magicString?: MagicString; chunks?: Record<string, ChunkGraphNode> },\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 = new CodeInjection();\n\n if (isInitialChunk(chunk, meta?.chunks)) {\n injectCode.append(releaseInjectionCode);\n }\n\n injectCode.append(chunkInjectionCode);\n\n if (sourcemapsEnabled && !hasExistingDebugID(code)) {\n const debugId = getDebugIdForChunk(code, !!this?.meta?.rolldownVersion);\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 * Resolves Rolldown's placeholder debug IDs, then stamps debug IDs into the emitted chunks and\n * 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(this: PluginContext | undefined, _outputOptions: unknown, bundle: OutputBundle): void {\n if (this?.meta?.rolldownVersion) {\n finalizeRolldownDebugIds(bundle);\n }\n\n if (options.sourcemaps?.disable !== 'disable-upload') {\n return;\n }\n\n stampDebugIds(bundle, true);\n }\n\n async function writeBundle(outputOptions: OutputDestinationOptions, bundle: OutputBundle | undefined): Promise<void> {\n const staging = await sourceMapHandling.takeStaging(outputOptions, bundle);\n let stagingHandedOver = false;\n\n try {\n await sentryBuildPluginManager.createRelease();\n\n if (sourcemapsEnabled && options.sourcemaps?.disable !== 'disable-upload') {\n let buildArtifacts: string[];\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 buildArtifacts = await globFiles(JS_AND_MAP_PATTERNS, { root: outputDir });\n } else if (outputOptions.file) {\n buildArtifacts = [outputOptions.file];\n } else {\n buildArtifacts = Object.keys(bundle ?? {}).map(asset => path.join(path.resolve(), asset));\n }\n stagingHandedOver = true;\n await upload(buildArtifacts, { staging });\n } else {\n stagingHandedOver = true;\n await staging?.discard();\n }\n } catch (e) {\n if (!stagingHandedOver) {\n await staging?.keep('The source map upload did not run.');\n }\n throw e;\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 // Vite warns about `rollupOptions.output.sourcemap`, so the Vite plugin\n // decides in a `config` hook instead.\n const viteSourceMapHooks =\n buildTool === 'vite' ? createViteSourceMapHooks(sentryBuildPluginManager, sourceMapHandling) : undefined;\n\n const main = {\n name,\n buildStart,\n ...(shouldTransform ? { transform: transformHook } : {}),\n ...(viteSourceMapHooks\n ? { configResolved: viteSourceMapHooks.configResolved }\n : { outputOptions: sourceMapHandling.outputOptions }),\n renderChunk,\n generateBundle: { order: 'pre' as const, handler: generateBundle },\n writeBundle,\n };\n\n const post = {\n name: buildTool === 'vite' ? 'sentry-vite-upload-staging' : 'sentry-rollup-upload-staging',\n // On the post plugin, so framework plugins that set `build.sourcemap`\n // themselves run first and the decision sees the merged setting.\n ...(viteSourceMapHooks ? { config: viteSourceMapHooks.config } : {}),\n generateBundle: {\n order: 'post' as const,\n async handler(outputOptions: OutputDestinationOptions, bundle: OutputBundle, isWrite?: boolean): Promise<void> {\n if (buildTool === 'vite' && options.sourcemaps?.disable === 'disable-upload') {\n // Vite's module preload rewrite in `generateBundle` regenerates the source map of every\n // chunk with a dynamic import, which drops the debug ID the main plugin stamped in its\n // `pre` hook. Restore it without touching the chunk code, so file hashes stay valid.\n stampDebugIds(bundle, false);\n }\n\n await sourceMapHandling.stageSourceMaps(outputOptions, bundle, isWrite);\n },\n },\n };\n\n return { main, post };\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 return _createRollupPluginInternals(userOptions, buildTool, buildToolMajorVersion).main;\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 const { main, post } = _createRollupPluginInternals(userOptions, 'rollup');\n // We return an array here so we don't break backwards compatibility with what\n // unplugin used to return\n return post ? [main, post] : [main];\n}\n\nexport type { Options as SentryRollupPluginOptions } from '../core';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAqCA,IAAI,wBAAA;AAKJ,MAAM,mBAAA,GAAsB,4BAAA;AAE5B,SAAS,qBAAA,GAA4C;AACnD,EAAA,IAAI;AAGF,IAAA,MAAM,GAAA,GAAM,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AACzC,IAAA,MAAM,MAAA,GAAS,IAAI,QAAQ,CAAA;AAC3B,IAAA,OAAO,MAAA,CAAO,OAAA,EAAS,KAAA,CAAM,GAAG,EAAE,CAAC,CAAA;AAAA,EACrC,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,oBAAA,GAA0D;AACjE,EAAA,IAAI,CAAC,wBAAA,EAA0B;AAC7B,IAAA,wBAAA,GAA2B,OAAA,CAAQ,OAAA,EAAQ,CACxC,IAAA,CAAK,YAAY;AAGhB,MAAA,MAAM,UAAA,GAAa,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,EAAE,MAAM,CAAA;AAExD,MAAA,IAAI,OAAO,UAAA,CAAW,aAAA,KAAkB,UAAA,EAAY;AAClD,QAAA,OAAO,IAAA;AAAA,MACT;AAEA,MAAA,IAAI;AACF,QAAA,MAAM,WAAW,aAAA,CAAc,oBAAA,EAAsB,EAAE,IAAA,EAAM,OAAO,CAAA;AAAA,MACtE,CAAA,CAAA,MAAQ;AACN,QAAA,OAAO,IAAA;AAAA,MACT;AAEA,MAAA,OAAO,UAAA,CAAW,aAAA;AAAA,IACpB,CAAC,CAAA,CACA,KAAA,CAAM,MAAM,IAAI,CAAA;AAAA,EACrB;AAEA,EAAA,OAAO,wBAAA;AACT;AAUO,SAAS,4BAAA,CACd,WAAA,GAAuB,EAAC,EACxB,WACA,qBAAA,EACA;AACA,EAAA,MAAM,wBAAA,GAA2B,+BAA+B,W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W,qBAAqB,CAAA,CAAE,IAAA;AACrF;AAGO,SAAS,kBAAA,CAAmB,WAAA,GAAuB,EAAC,EAAQ;AACjE,EAAA,MAAM,EAAE,IAAA,EAAM,IAAA,EAAK,GAAI,4BAAA,CAA6B,aAAa,QAAQ,CAAA;AAGzE,EAAA,OAAO,OAAO,CAAC,IAAA,EAAM,IAAI,CAAA,GAAI,CAAC,IAAI,CAAA;AACpC;;;;"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import { isJsFile } from '../core/index.js';
|
|
3
|
+
|
|
4
|
+
function sourceMapKindFromRollupSetting(setting) {
|
|
5
|
+
switch (setting) {
|
|
6
|
+
case void 0:
|
|
7
|
+
return "unset";
|
|
8
|
+
case false:
|
|
9
|
+
return "off";
|
|
10
|
+
case true:
|
|
11
|
+
return "visible";
|
|
12
|
+
default:
|
|
13
|
+
return setting;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function getOutputDestination(outputOptions) {
|
|
17
|
+
return path.resolve(outputOptions.dir ?? path.dirname(outputOptions.file ?? "."));
|
|
18
|
+
}
|
|
19
|
+
const MATCH_KEYS = [
|
|
20
|
+
"dir",
|
|
21
|
+
"file",
|
|
22
|
+
"format",
|
|
23
|
+
"entryFileNames",
|
|
24
|
+
"chunkFileNames",
|
|
25
|
+
"preserveModules",
|
|
26
|
+
"sourcemap"
|
|
27
|
+
];
|
|
28
|
+
function normalizeFormat(format) {
|
|
29
|
+
switch (format) {
|
|
30
|
+
case "esm":
|
|
31
|
+
case "module":
|
|
32
|
+
return "es";
|
|
33
|
+
case "commonjs":
|
|
34
|
+
return "cjs";
|
|
35
|
+
case "systemjs":
|
|
36
|
+
return "system";
|
|
37
|
+
default:
|
|
38
|
+
return format;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function getOutputMatch(outputOptions) {
|
|
42
|
+
const match = {};
|
|
43
|
+
for (const key of MATCH_KEYS) {
|
|
44
|
+
const value = outputOptions[key];
|
|
45
|
+
if (value === void 0) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
match[key] = key === "format" ? normalizeFormat(value) : key === "dir" || key === "file" ? path.resolve(String(value)) : value;
|
|
49
|
+
}
|
|
50
|
+
return match;
|
|
51
|
+
}
|
|
52
|
+
function matchesOutput(match, outputOptions) {
|
|
53
|
+
const actual = getOutputMatch(outputOptions);
|
|
54
|
+
return MATCH_KEYS.every((key) => match[key] === void 0 || match[key] === actual[key]);
|
|
55
|
+
}
|
|
56
|
+
function isSameMatch(a, b) {
|
|
57
|
+
return MATCH_KEYS.every((key) => a[key] === b[key]);
|
|
58
|
+
}
|
|
59
|
+
function countMatchFields(match) {
|
|
60
|
+
return MATCH_KEYS.filter((key) => match[key] !== void 0).length;
|
|
61
|
+
}
|
|
62
|
+
const DEBUG_ID_PATTERN = /sentry-dbid-([0-9a-f-]{36})|\/\/# debugId=([0-9a-f-]{36})/i;
|
|
63
|
+
function getBundleSignature(bundle) {
|
|
64
|
+
const entries = [];
|
|
65
|
+
for (const output of Object.values(bundle)) {
|
|
66
|
+
if (output.type === "chunk" && isJsFile(output.fileName)) {
|
|
67
|
+
const match = output.code.match(DEBUG_ID_PATTERN);
|
|
68
|
+
entries.push(`${output.fileName}:${match?.[1] ?? match?.[2] ?? ""}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return entries.sort().join("\n");
|
|
72
|
+
}
|
|
73
|
+
function getSourceMapFileName(output) {
|
|
74
|
+
return output.sourcemapFileName ?? `${output.fileName}.map`;
|
|
75
|
+
}
|
|
76
|
+
function createSourceMapHandling(sentryBuildPluginManager) {
|
|
77
|
+
const decisions = /* @__PURE__ */ new Map();
|
|
78
|
+
const pendingStagings = /* @__PURE__ */ new Map();
|
|
79
|
+
function setDecision(destination, record) {
|
|
80
|
+
const records = decisions.get(destination) ?? [];
|
|
81
|
+
const index = records.findIndex((existing) => isSameMatch(existing.match, record.match));
|
|
82
|
+
if (index === -1) {
|
|
83
|
+
records.push(record);
|
|
84
|
+
} else {
|
|
85
|
+
records[index] = record;
|
|
86
|
+
}
|
|
87
|
+
decisions.set(destination, records);
|
|
88
|
+
}
|
|
89
|
+
function findDecision(destination, outputOptions) {
|
|
90
|
+
const candidates = (decisions.get(destination) ?? []).filter((record) => matchesOutput(record.match, outputOptions));
|
|
91
|
+
return candidates.sort((a, b) => countMatchFields(b.match) - countMatchFields(a.match))[0];
|
|
92
|
+
}
|
|
93
|
+
function dropSourceMaps(bundle) {
|
|
94
|
+
for (const output of Object.values(bundle)) {
|
|
95
|
+
if (output.type === "chunk" && isJsFile(output.fileName)) {
|
|
96
|
+
delete bundle[getSourceMapFileName(output)];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
outputOptions: (rawOutputOptions) => {
|
|
102
|
+
const kind = sourceMapKindFromRollupSetting(rawOutputOptions.sourcemap);
|
|
103
|
+
const decision = sentryBuildPluginManager.sourceMaps.decide(kind, { log: false });
|
|
104
|
+
const outputOptions = decision.enableHidden ? { ...rawOutputOptions, sourcemap: "hidden" } : rawOutputOptions;
|
|
105
|
+
setDecision(getOutputDestination(rawOutputOptions), { match: getOutputMatch(outputOptions), kind, decision });
|
|
106
|
+
return decision.enableHidden ? outputOptions : null;
|
|
107
|
+
},
|
|
108
|
+
setDecision,
|
|
109
|
+
stageSourceMaps: async (outputOptions, bundle, isWrite) => {
|
|
110
|
+
const destination = getOutputDestination(outputOptions);
|
|
111
|
+
const record = findDecision(destination, outputOptions);
|
|
112
|
+
if (!record) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (isWrite === false) {
|
|
116
|
+
if (record.kind === "unset" && record.decision.enableHidden) {
|
|
117
|
+
dropSourceMaps(bundle);
|
|
118
|
+
}
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
sentryBuildPluginManager.sourceMaps.logDecision(record.decision);
|
|
122
|
+
if (!record.decision.deleteAfterUpload) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const staging = await sentryBuildPluginManager.createUploadStaging();
|
|
126
|
+
try {
|
|
127
|
+
for (const output of Object.values(bundle)) {
|
|
128
|
+
if (output.type !== "chunk" || !isJsFile(output.fileName)) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const mapFileName = getSourceMapFileName(output);
|
|
132
|
+
const mapAsset = bundle[mapFileName];
|
|
133
|
+
if (mapAsset?.type !== "asset" || typeof mapAsset.source !== "string") {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
const result = await staging.stage({
|
|
137
|
+
code: output.code,
|
|
138
|
+
mapSource: mapAsset.source,
|
|
139
|
+
mapDir: path.join(destination, path.dirname(mapFileName)),
|
|
140
|
+
chunkPath: path.join(destination, output.fileName)
|
|
141
|
+
});
|
|
142
|
+
if (result === "staged" || record.kind === "unset") {
|
|
143
|
+
delete bundle[mapFileName];
|
|
144
|
+
}
|
|
145
|
+
if (result === "skipped" || result === "failed") {
|
|
146
|
+
sentryBuildPluginManager.logger.warn(
|
|
147
|
+
record.kind === "unset" ? `Could not prepare ${output.fileName} for upload, so it is not uploaded and its source map ${mapFileName} was removed from the build output.` : `Could not prepare ${output.fileName} for upload, so its source map ${mapFileName} stays in the build output.`
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
} catch (e) {
|
|
152
|
+
await staging.discard();
|
|
153
|
+
throw e;
|
|
154
|
+
}
|
|
155
|
+
const stagings = pendingStagings.get(destination) ?? [];
|
|
156
|
+
pendingStagings.set(destination, stagings);
|
|
157
|
+
const superseded = stagings.filter((pending) => isSameMatch(pending.match, record.match));
|
|
158
|
+
for (const pending of superseded) {
|
|
159
|
+
stagings.splice(stagings.indexOf(pending), 1);
|
|
160
|
+
}
|
|
161
|
+
stagings.push({ staging, signature: getBundleSignature(bundle), match: record.match });
|
|
162
|
+
for (const pending of superseded) {
|
|
163
|
+
sentryBuildPluginManager.logger.debug(
|
|
164
|
+
`Discarding staged source maps of an earlier build of ${destination} that was never written.`
|
|
165
|
+
);
|
|
166
|
+
await pending.staging.discard();
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
takeStaging: async (outputOptions, bundle) => {
|
|
170
|
+
const destination = getOutputDestination(outputOptions);
|
|
171
|
+
const stagings = pendingStagings.get(destination) ?? [];
|
|
172
|
+
if (!bundle) {
|
|
173
|
+
return stagings.shift()?.staging;
|
|
174
|
+
}
|
|
175
|
+
const signature = getBundleSignature(bundle);
|
|
176
|
+
const index = stagings.findIndex((pending) => pending.signature === signature);
|
|
177
|
+
return index === -1 ? void 0 : stagings.splice(index, 1)[0]?.staging;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export { createSourceMapHandling, getOutputDestination, getOutputMatch, sourceMapKindFromRollupSetting };
|
|
183
|
+
//# sourceMappingURL=source-map-handling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-map-handling.js","sources":["../../../src/rollup/source-map-handling.ts"],"sourcesContent":["import * as path from 'node:path';\nimport type { SentryBuildPluginManager, SourceMapDecision, SourceMapKind, UploadStaging } from '../core';\nimport { isJsFile } from '../core';\nimport type { OutputBundle } from './debug-id-stamping';\n\nexport type RollupSourceMapSetting = boolean | 'inline' | 'hidden' | undefined;\n\nexport type OutputDestinationOptions = { dir?: string; file?: string };\n\n/**\n * The output options that tell outputs of one directory apart. Several outputs can write into the\n * same directory at once, for example an ES and a CJS build, each with its own `sourcemap` setting.\n * `sourcemap` holds the setting as the plugin left it, so an output it switched to hidden maps\n * differs from one the user set.\n */\nexport type OutputMatch = {\n dir?: unknown;\n file?: unknown;\n format?: unknown;\n entryFileNames?: unknown;\n chunkFileNames?: unknown;\n preserveModules?: unknown;\n sourcemap?: unknown;\n};\n\nexport type OutputOptions = OutputDestinationOptions & OutputMatch & { sourcemap?: RollupSourceMapSetting };\n\n/** Maps Rollup's (and Vite's) `sourcemap` setting onto the plugin's source map kinds. */\nexport function sourceMapKindFromRollupSetting(setting: RollupSourceMapSetting): SourceMapKind {\n switch (setting) {\n case undefined:\n return 'unset';\n case false:\n return 'off';\n case true:\n return 'visible';\n default:\n return setting;\n }\n}\n\n/** The directory an output writes to. Decisions and stagings are keyed by it. */\nexport function getOutputDestination(outputOptions: OutputDestinationOptions): string {\n return path.resolve(outputOptions.dir ?? path.dirname(outputOptions.file ?? '.'));\n}\n\nconst MATCH_KEYS = [\n 'dir',\n 'file',\n 'format',\n 'entryFileNames',\n 'chunkFileNames',\n 'preserveModules',\n 'sourcemap',\n] as const;\n\n/** The raw options accept aliases that the normalized options do not carry. */\nfunction normalizeFormat(format: unknown): unknown {\n switch (format) {\n case 'esm':\n case 'module':\n return 'es';\n case 'commonjs':\n return 'cjs';\n case 'systemjs':\n return 'system';\n default:\n return format;\n }\n}\n\n/** The fields of `OutputMatch` an output sets, in the form the normalized options carry them. */\nexport function getOutputMatch(outputOptions: OutputMatch): OutputMatch {\n const match: OutputMatch = {};\n for (const key of MATCH_KEYS) {\n const value = outputOptions[key];\n if (value === undefined) {\n continue;\n }\n match[key] =\n key === 'format' ? normalizeFormat(value) : key === 'dir' || key === 'file' ? path.resolve(String(value)) : value;\n }\n return match;\n}\n\nfunction matchesOutput(match: OutputMatch, outputOptions: OutputMatch): boolean {\n const actual = getOutputMatch(outputOptions);\n return MATCH_KEYS.every(key => match[key] === undefined || match[key] === actual[key]);\n}\n\nfunction isSameMatch(a: OutputMatch, b: OutputMatch): boolean {\n return MATCH_KEYS.every(key => a[key] === b[key]);\n}\n\nfunction countMatchFields(match: OutputMatch): number {\n return MATCH_KEYS.filter(key => match[key] !== undefined).length;\n}\n\nconst DEBUG_ID_PATTERN = /sentry-dbid-([0-9a-f-]{36})|\\/\\/# debugId=([0-9a-f-]{36})/i;\n\n/** Identifies the chunks of a bundle by name and debug ID, so a staging can be matched to its write. */\nfunction getBundleSignature(bundle: OutputBundle): string {\n const entries: string[] = [];\n for (const output of Object.values(bundle)) {\n if (output.type === 'chunk' && isJsFile(output.fileName)) {\n const match = output.code.match(DEBUG_ID_PATTERN);\n entries.push(`${output.fileName}:${match?.[1] ?? match?.[2] ?? ''}`);\n }\n }\n return entries.sort().join('\\n');\n}\n\nfunction getSourceMapFileName(output: { fileName: string; sourcemapFileName?: string | null }): string {\n return output.sourcemapFileName ?? `${output.fileName}.map`;\n}\n\ntype PendingStaging = { staging: UploadStaging; signature: string; match: OutputMatch };\n\nexport type DecisionRecord = { match: OutputMatch; kind: SourceMapKind; decision: SourceMapDecision };\n\nexport type SourceMapHandling = {\n /** Rollup's `outputOptions` hook: decides for the output and switches it to hidden source maps when needed. */\n outputOptions: (rawOutputOptions: OutputOptions) => OutputOptions | null;\n /** Records the decision for an output, for bundlers that decide outside `outputOptions`. */\n setDecision: (destination: string, record: DecisionRecord) => void;\n /**\n * `generateBundle` with `order: 'post'`: copies each chunk and its source map into a staging folder\n * and drops the map asset from the bundle, so the bundler never writes it.\n */\n stageSourceMaps: (outputOptions: OutputOptions, bundle: OutputBundle, isWrite?: boolean) => Promise<void>;\n /**\n * Hands the staging of this bundle to `writeBundle`. Without a bundle (SvelteKit calls the hook\n * with output options only) the oldest staging is taken.\n */\n takeStaging: (\n outputOptions: OutputDestinationOptions,\n bundle: OutputBundle | undefined,\n ) => Promise<UploadStaging | undefined>;\n};\n\n/**\n * Source map decisions and upload stagings of one plugin instance. Keyed by output destination\n * because one instance can serve several outputs, and watch mode or several `write()` calls\n * rebuild the same one. Outputs that share a directory are told apart by `OutputMatch`.\n */\nexport function createSourceMapHandling(sentryBuildPluginManager: SentryBuildPluginManager): SourceMapHandling {\n const decisions = new Map<string, DecisionRecord[]>();\n const pendingStagings = new Map<string, PendingStaging[]>();\n\n function setDecision(destination: string, record: DecisionRecord): void {\n const records = decisions.get(destination) ?? [];\n const index = records.findIndex(existing => isSameMatch(existing.match, record.match));\n if (index === -1) {\n records.push(record);\n } else {\n records[index] = record;\n }\n decisions.set(destination, records);\n }\n\n function findDecision(destination: string, outputOptions: OutputOptions): DecisionRecord | undefined {\n const candidates = (decisions.get(destination) ?? []).filter(record => matchesOutput(record.match, outputOptions));\n // The record that sets the most fields describes this output best. Equal\n // candidates keep their order, so the first one recorded wins.\n return candidates.sort((a, b) => countMatchFields(b.match) - countMatchFields(a.match))[0];\n }\n\n function dropSourceMaps(bundle: OutputBundle): void {\n for (const output of Object.values(bundle)) {\n if (output.type === 'chunk' && isJsFile(output.fileName)) {\n // oxlint-disable-next-line typescript/no-dynamic-delete -- Rollup drops an asset when its key is deleted from the bundle\n delete bundle[getSourceMapFileName(output)];\n }\n }\n }\n\n return {\n outputOptions: rawOutputOptions => {\n const kind = sourceMapKindFromRollupSetting(rawOutputOptions.sourcemap);\n // Logged in `generateBundle`, which knows whether the output is written.\n const decision = sentryBuildPluginManager.sourceMaps.decide(kind, { log: false });\n const outputOptions = decision.enableHidden\n ? { ...rawOutputOptions, sourcemap: 'hidden' as const }\n : rawOutputOptions;\n setDecision(getOutputDestination(rawOutputOptions), { match: getOutputMatch(outputOptions), kind, decision });\n\n return decision.enableHidden ? outputOptions : null;\n },\n\n setDecision,\n\n stageSourceMaps: async (outputOptions, bundle, isWrite) => {\n const destination = getOutputDestination(outputOptions);\n const record = findDecision(destination, outputOptions);\n if (!record) {\n return;\n }\n\n // `generate()` never reaches `writeBundle`, so nothing would upload a staging. Maps the\n // plugin turned on are dropped, so the result holds what the user configured.\n if (isWrite === false) {\n if (record.kind === 'unset' && record.decision.enableHidden) {\n dropSourceMaps(bundle);\n }\n return;\n }\n\n sentryBuildPluginManager.sourceMaps.logDecision(record.decision);\n if (!record.decision.deleteAfterUpload) {\n return;\n }\n\n const staging = await sentryBuildPluginManager.createUploadStaging();\n\n try {\n for (const output of Object.values(bundle)) {\n if (output.type !== 'chunk' || !isJsFile(output.fileName)) {\n continue;\n }\n\n const mapFileName = getSourceMapFileName(output);\n const mapAsset = bundle[mapFileName];\n if (mapAsset?.type !== 'asset' || typeof mapAsset.source !== 'string') {\n continue;\n }\n\n const result = await staging.stage({\n code: output.code,\n mapSource: mapAsset.source,\n mapDir: path.join(destination, path.dirname(mapFileName)),\n chunkPath: path.join(destination, output.fileName),\n });\n\n // A map the plugin turned on never reaches the output, whether or\n // not the chunk is uploaded. A map the user enabled stays unless\n // it was staged.\n if (result === 'staged' || record.kind === 'unset') {\n // oxlint-disable-next-line typescript/no-dynamic-delete -- Rollup drops an asset when its key is deleted from the bundle\n delete bundle[mapFileName];\n }\n if (result === 'skipped' || result === 'failed') {\n sentryBuildPluginManager.logger.warn(\n record.kind === 'unset'\n ? `Could not prepare ${output.fileName} for upload, so it is not uploaded and its source map ${mapFileName} was removed from the build output.`\n : `Could not prepare ${output.fileName} for upload, so its source map ${mapFileName} stays in the build output.`,\n );\n }\n }\n } catch (e) {\n // The error fails the build before anything is written.\n await staging.discard();\n throw e;\n }\n\n // A staging of the same output that no `writeBundle` took belongs to a\n // write that never finished. Stagings of other outputs to this directory\n // may still be in flight, so the shared list changes in place and without\n // an await in between.\n const stagings = pendingStagings.get(destination) ?? [];\n pendingStagings.set(destination, stagings);\n const superseded = stagings.filter(pending => isSameMatch(pending.match, record.match));\n for (const pending of superseded) {\n stagings.splice(stagings.indexOf(pending), 1);\n }\n stagings.push({ staging, signature: getBundleSignature(bundle), match: record.match });\n\n for (const pending of superseded) {\n sentryBuildPluginManager.logger.debug(\n `Discarding staged source maps of an earlier build of ${destination} that was never written.`,\n );\n await pending.staging.discard();\n }\n },\n\n takeStaging: async (outputOptions, bundle) => {\n const destination = getOutputDestination(outputOptions);\n const stagings = pendingStagings.get(destination) ?? [];\n\n if (!bundle) {\n return stagings.shift()?.staging;\n }\n\n const signature = getBundleSignature(bundle);\n const index = stagings.findIndex(pending => pending.signature === signature);\n return index === -1 ? undefined : stagings.splice(index, 1)[0]?.staging;\n },\n };\n}\n"],"names":[],"mappings":";;;AA4BO,SAAS,+BAA+B,OAAA,EAAgD;AAC7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EtD,MAAA,IAAI,CAAC,MAAA,EAAQ;AACX,QAAA,OAAO,QAAA,CAAS,OAAM,EAAG,OAAA;AAAA,MAC3B;AAEA,MAAA,MAAM,SAAA,GAAY,mBAAmB,MAAM,CAAA;AAC3C,MAAA,MAAM,QAAQ,QAAA,CAAS,SAAA,CAAU,CAAA,OAAA,KAAW,OAAA,CAAQ,cAAc,SAAS,CAAA;AAC3E,MAAA,OAAO,KAAA,KAAU,KAAK,MAAA,GAAY,QAAA,CAAS,OAAO,KAAA,EAAO,CAAC,CAAA,CAAE,CAAC,CAAA,EAAG,OAAA;AAAA,IAClE;AAAA,GACF;AACF;;;;"}
|
package/build/esm/vite/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _createRollupPluginInternals } from '../rollup/index.js';
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
-
import { stampDebugIds } from '../rollup/debug-id-stamping.js';
|
|
4
3
|
|
|
5
4
|
function getViteMajorVersion() {
|
|
6
5
|
try {
|
|
@@ -12,23 +11,10 @@ function getViteMajorVersion() {
|
|
|
12
11
|
return void 0;
|
|
13
12
|
}
|
|
14
13
|
const sentryVitePlugin = (options) => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
];
|
|
21
|
-
if (!options?.disable && options?.sourcemaps?.disable === "disable-upload") {
|
|
22
|
-
plugins.push({
|
|
23
|
-
name: "sentry-vite-debug-id-sourcemaps",
|
|
24
|
-
enforce: "post",
|
|
25
|
-
generateBundle: {
|
|
26
|
-
order: "post",
|
|
27
|
-
handler(_outputOptions, bundle) {
|
|
28
|
-
stampDebugIds(bundle, false);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
});
|
|
14
|
+
const { main, post } = _createRollupPluginInternals(options, "vite", getViteMajorVersion());
|
|
15
|
+
const plugins = [{ enforce: "pre", ...main }];
|
|
16
|
+
if (post) {
|
|
17
|
+
plugins.push({ enforce: "post", ...post });
|
|
32
18
|
}
|
|
33
19
|
return plugins;
|
|
34
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/vite/index.ts"],"sourcesContent":["import type { SentryRollupPluginOptions } from '../rollup';\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/vite/index.ts"],"sourcesContent":["import type { SentryRollupPluginOptions } from '../rollup';\nimport { _createRollupPluginInternals } from '../rollup';\nimport { createRequire } from 'node:module';\n\ninterface SentryVitePlugin {\n name: string;\n enforce: 'pre' | 'post';\n [hook: string]: unknown;\n}\n\nfunction getViteMajorVersion(): 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 vite = req('vite') as { version?: string };\n return vite.version?.split('.')[0];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nexport const sentryVitePlugin = (options?: SentryRollupPluginOptions): SentryVitePlugin[] => {\n const { main, post } = _createRollupPluginInternals(options, 'vite', getViteMajorVersion());\n\n const plugins: SentryVitePlugin[] = [{ enforce: 'pre', ...main }];\n\n if (post) {\n plugins.push({ enforce: 'post', ...post });\n }\n\n return plugins;\n};\n\nexport type { Options as SentryVitePluginOptions } from '../core';\n"],"names":[],"mappings":";;;AAUA,SAAS,mBAAA,GAA0C;AACjD,EAAA,IAAI;AAGF,IAAA,MAAM,GAAA,GAAM,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AACzC,IAAA,MAAM,IAAA,GAAO,IAAI,MAAM,CAAA;AACvB,IAAA,OAAO,IAAA,CAAK,OAAA,EAAS,KAAA,CAAM,GAAG,EAAE,CAAC,CAAA;AAAA,EACnC,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,OAAO,MAAA;AACT;AAEO,MAAM,gBAAA,GAAmB,CAAC,OAAA,KAA4D;AAC3F,EAAA,MAAM,EAAE,MAAM,IAAA,EAAK,GAAI,6BAA6B,OAAA,EAAS,MAAA,EAAQ,qBAAqB,CAAA;AAE1F,EAAA,MAAM,UAA8B,CAAC,EAAE,SAAS,KAAA,EAAO,GAAG,MAAM,CAAA;AAEhE,EAAA,IAAI,IAAA,EAAM;AACR,IAAA,OAAA,CAAQ,KAAK,EAAE,OAAA,EAAS,MAAA,EAAQ,GAAG,MAAM,CAAA;AAAA,EAC3C;AAEA,EAAA,OAAO,OAAA;AACT;;;;"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import { sourceMapKindFromRollupSetting, getOutputMatch } from '../rollup/source-map-handling.js';
|
|
3
|
+
|
|
4
|
+
const NO_CHANGE = { enableHidden: false, deleteAfterUpload: false };
|
|
5
|
+
function getOutputs(root, build) {
|
|
6
|
+
const configured = build.rolldownOptions?.output ?? build.rollupOptions?.output;
|
|
7
|
+
const outputs = Array.isArray(configured) ? configured : [configured ?? {}];
|
|
8
|
+
return outputs.map((output) => {
|
|
9
|
+
const sourcemap = output.sourcemap ?? build.sourcemap;
|
|
10
|
+
return {
|
|
11
|
+
destination: output.dir === void 0 ? path.resolve(root, build.outDir ?? "dist") : path.resolve(output.dir),
|
|
12
|
+
match: getOutputMatch({ ...output, sourcemap }),
|
|
13
|
+
sourcemap,
|
|
14
|
+
ownSetting: output.sourcemap !== void 0
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function createViteSourceMapHooks(sentryBuildPluginManager, sourceMapHandling) {
|
|
19
|
+
const decisions = /* @__PURE__ */ new Map();
|
|
20
|
+
return {
|
|
21
|
+
config: (userConfig, env) => {
|
|
22
|
+
if (env.command !== "build") {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
decisions.clear();
|
|
26
|
+
const kind = sourceMapKindFromRollupSetting(userConfig.build?.sourcemap);
|
|
27
|
+
const decision = sentryBuildPluginManager.sourceMaps.decide(kind, { log: false });
|
|
28
|
+
decisions.set("*", { kind, decision });
|
|
29
|
+
const result = decision.enableHidden ? { build: { sourcemap: "hidden" } } : {};
|
|
30
|
+
for (const [name, environment] of Object.entries(userConfig.environments ?? {})) {
|
|
31
|
+
const setting = environment?.build?.sourcemap;
|
|
32
|
+
if (setting === void 0) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const environmentKind = sourceMapKindFromRollupSetting(setting);
|
|
36
|
+
const environmentDecision = sentryBuildPluginManager.sourceMaps.decide(environmentKind, { log: false });
|
|
37
|
+
decisions.set(name, { kind: environmentKind, decision: environmentDecision });
|
|
38
|
+
if (environmentDecision.enableHidden) {
|
|
39
|
+
result.environments = { ...result.environments, [name]: { build: { sourcemap: "hidden" } } };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
},
|
|
44
|
+
configResolved: (config) => {
|
|
45
|
+
const environments = config.environments ?? { client: { build: config.build } };
|
|
46
|
+
const { uploadPossible } = sentryBuildPluginManager.sourceMaps;
|
|
47
|
+
const deleteOption = sentryBuildPluginManager.normalizedOptions.sourcemaps?.deleteSourcemapsAfterUpload;
|
|
48
|
+
for (const [name, environment] of Object.entries(environments)) {
|
|
49
|
+
const { kind, decision } = decisions.get(name) ?? decisions.get("*") ?? { kind: "unset", decision: NO_CHANGE };
|
|
50
|
+
for (const output of getOutputs(config.root, environment.build)) {
|
|
51
|
+
if (output.ownSetting) {
|
|
52
|
+
sourceMapHandling.setDecision(output.destination, {
|
|
53
|
+
match: output.match,
|
|
54
|
+
kind: sourceMapKindFromRollupSetting(output.sourcemap),
|
|
55
|
+
decision: {
|
|
56
|
+
enableHidden: false,
|
|
57
|
+
deleteAfterUpload: uploadPossible && deleteOption === true && output.sourcemap === "hidden"
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (decision.deleteAfterUpload && output.sourcemap !== "hidden") {
|
|
63
|
+
sentryBuildPluginManager.logger.debug(
|
|
64
|
+
`Source maps of the "${name}" environment are set to ${JSON.stringify(output.sourcemap)}. Not removing them after upload.`
|
|
65
|
+
);
|
|
66
|
+
sourceMapHandling.setDecision(output.destination, { match: output.match, kind, decision: NO_CHANGE });
|
|
67
|
+
} else {
|
|
68
|
+
sourceMapHandling.setDecision(output.destination, { match: output.match, kind, decision });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { createViteSourceMapHooks };
|
|
77
|
+
//# sourceMappingURL=source-map-hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-map-hooks.js","sources":["../../../src/vite/source-map-hooks.ts"],"sourcesContent":["import * as path from 'node:path';\nimport type { SentryBuildPluginManager, SourceMapDecision, SourceMapKind } from '../core';\nimport type { OutputMatch, RollupSourceMapSetting, SourceMapHandling } from '../rollup/source-map-handling';\nimport { getOutputMatch, sourceMapKindFromRollupSetting } from '../rollup/source-map-handling';\n\ntype BundlerOutput = OutputMatch & { dir?: string; sourcemap?: RollupSourceMapSetting };\ntype BundlerOutputOptions = BundlerOutput | BundlerOutput[] | undefined;\n\ntype ViteBuildOptions = {\n sourcemap?: RollupSourceMapSetting;\n outDir?: string;\n rollupOptions?: { output?: BundlerOutputOptions };\n rolldownOptions?: { output?: BundlerOutputOptions };\n};\n\nexport type ViteUserConfig = {\n build?: ViteBuildOptions;\n environments?: Record<string, { build?: ViteBuildOptions } | undefined>;\n};\n\nexport type ViteResolvedConfig = {\n root: string;\n build: ViteBuildOptions;\n environments?: Record<string, { build: ViteBuildOptions }>;\n};\n\nexport type ViteSourceMapHooks = {\n config: (userConfig: ViteUserConfig, env: { command: string }) => ViteUserConfig | null;\n configResolved: (config: ViteResolvedConfig) => void;\n};\n\nconst NO_CHANGE: SourceMapDecision = { enableHidden: false, deleteAfterUpload: false };\n\ntype EnvironmentOutput = {\n destination: string;\n match: OutputMatch;\n sourcemap: RollupSourceMapSetting;\n /** The output sets `sourcemap` itself, which overrides `build.sourcemap`. */\n ownSetting: boolean;\n};\n\n/**\n * The outputs an environment writes: one per entry of `rollupOptions.output` or\n * `rolldownOptions.output`. An output writes to `build.outDir` (relative to the root) unless it\n * sets its own `dir`, which the bundler resolves from the working directory. An output's own\n * `sourcemap` overrides `build.sourcemap`.\n */\nfunction getOutputs(root: string, build: ViteBuildOptions): EnvironmentOutput[] {\n const configured = build.rolldownOptions?.output ?? build.rollupOptions?.output;\n const outputs = Array.isArray(configured) ? configured : [configured ?? {}];\n\n return outputs.map(output => {\n const sourcemap = output.sourcemap ?? build.sourcemap;\n return {\n destination: output.dir === undefined ? path.resolve(root, build.outDir ?? 'dist') : path.resolve(output.dir),\n match: getOutputMatch({ ...output, sourcemap }),\n sourcemap,\n ownSetting: output.sourcemap !== undefined,\n };\n });\n}\n\n/**\n * Vite warns about `rollupOptions.output.sourcemap`, so the Vite plugin decides on `build.sourcemap`\n * in a `config` hook. The hook belongs on the post plugin: framework plugins that set\n * `build.sourcemap` themselves run first, and the decision sees the merged setting. The output\n * directories are only known in `configResolved`, which then records the decision for each of them.\n */\nexport function createViteSourceMapHooks(\n sentryBuildPluginManager: SentryBuildPluginManager,\n sourceMapHandling: SourceMapHandling,\n): ViteSourceMapHooks {\n // `'*'` for the top-level setting, otherwise the name of an environment with its own.\n const decisions = new Map<string, { kind: SourceMapKind; decision: SourceMapDecision }>();\n\n return {\n config: (userConfig, env) => {\n if (env.command !== 'build') {\n return null;\n }\n\n // The same plugin instances can serve several builds in a row.\n decisions.clear();\n\n const kind = sourceMapKindFromRollupSetting(userConfig.build?.sourcemap);\n // Logged in `generateBundle`, which knows whether the output is written.\n const decision = sentryBuildPluginManager.sourceMaps.decide(kind, { log: false });\n decisions.set('*', { kind, decision });\n\n const result: ViteUserConfig = decision.enableHidden ? { build: { sourcemap: 'hidden' } } : {};\n\n for (const [name, environment] of Object.entries(userConfig.environments ?? {})) {\n const setting = environment?.build?.sourcemap;\n if (setting === undefined) {\n continue;\n }\n\n const environmentKind = sourceMapKindFromRollupSetting(setting);\n const environmentDecision = sentryBuildPluginManager.sourceMaps.decide(environmentKind, { log: false });\n decisions.set(name, { kind: environmentKind, decision: environmentDecision });\n\n if (environmentDecision.enableHidden) {\n result.environments = { ...result.environments, [name]: { build: { sourcemap: 'hidden' } } };\n }\n }\n\n return result;\n },\n\n configResolved: config => {\n const environments = config.environments ?? { client: { build: config.build } };\n\n const { uploadPossible } = sentryBuildPluginManager.sourceMaps;\n const deleteOption = sentryBuildPluginManager.normalizedOptions.sourcemaps?.deleteSourcemapsAfterUpload;\n\n for (const [name, environment] of Object.entries(environments)) {\n const { kind, decision } = decisions.get(name) ?? decisions.get('*') ?? { kind: 'unset', decision: NO_CHANGE };\n\n for (const output of getOutputs(config.root, environment.build)) {\n // The plugin never changes an output's own setting, so the user enabled\n // these maps: only hidden ones the user asked to delete are removed.\n if (output.ownSetting) {\n sourceMapHandling.setDecision(output.destination, {\n match: output.match,\n kind: sourceMapKindFromRollupSetting(output.sourcemap),\n decision: {\n enableHidden: false,\n deleteAfterUpload: uploadPossible && deleteOption === true && output.sourcemap === 'hidden',\n },\n });\n continue;\n }\n\n // A plugin that ran after ours may have changed the setting again.\n if (decision.deleteAfterUpload && output.sourcemap !== 'hidden') {\n sentryBuildPluginManager.logger.debug(\n `Source maps of the \"${name}\" environment are set to ${JSON.stringify(output.sourcemap)}. Not removing them after upload.`,\n );\n sourceMapHandling.setDecision(output.destination, { match: output.match, kind, decision: NO_CHANGE });\n } else {\n sourceMapHandling.setDecision(output.destination, { match: output.match, kind, decision });\n }\n }\n }\n },\n };\n}\n"],"names":[],"mappings":";;;AA+BA,MAAM,SAAA,GAA+B,EAAE,YAAA,EAAc,KAAA,EAAO,mBAAmB,KAAA,EAAM;AAgBrF,SAAS,UAAA,CAAW,MAAc,KAAA,EAA8C;AAC9E,EAAA,MAAM,UAAA,GAAa,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