@sentry/bundler-plugins 11.12.0 → 11.14.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/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/assertClassBrand.js +6 -0
- package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/checkPrivateRedeclaration.js +5 -0
- package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldGet2.js +6 -0
- package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldInitSpec.js +6 -0
- package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldSet2.js +6 -0
- package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateMethodInitSpec.js +6 -0
- package/build/cjs/_virtual/_rolldown/runtime.js +22 -0
- package/build/cjs/babel-plugin/component-annotation.js +14 -32
- package/build/cjs/babel-plugin/component-annotation.js.map +1 -1
- package/build/cjs/babel-plugin/constants.js +140 -122
- package/build/cjs/babel-plugin/constants.js.map +1 -1
- package/build/cjs/babel-plugin/experimental.js +204 -307
- package/build/cjs/babel-plugin/experimental.js.map +1 -1
- package/build/cjs/babel-plugin/index.js +315 -437
- package/build/cjs/babel-plugin/index.js.map +1 -1
- package/build/cjs/bun/index.js +81 -117
- package/build/cjs/bun/index.js.map +1 -1
- package/build/cjs/core/build-plugin-manager.js +626 -702
- package/build/cjs/core/build-plugin-manager.js.map +1 -1
- package/build/cjs/core/cli.js +134 -129
- package/build/cjs/core/cli.js.map +1 -1
- package/build/cjs/core/component-annotate-hooks.js +16 -27
- package/build/cjs/core/component-annotate-hooks.js.map +1 -1
- package/build/cjs/core/component-annotation-oxc-ast.js +10 -21
- package/build/cjs/core/component-annotation-oxc-ast.js.map +1 -1
- package/build/cjs/core/component-annotation-oxc-fragments.js +45 -74
- package/build/cjs/core/component-annotation-oxc-fragments.js.map +1 -1
- package/build/cjs/core/component-annotation-oxc-jsx.js +116 -156
- package/build/cjs/core/component-annotation-oxc-jsx.js.map +1 -1
- package/build/cjs/core/component-annotation-oxc-walk.js +62 -123
- package/build/cjs/core/component-annotation-oxc-walk.js.map +1 -1
- package/build/cjs/core/component-annotation-oxc.js +68 -103
- package/build/cjs/core/component-annotation-oxc.js.map +1 -1
- package/build/cjs/core/debug-id-upload.js +223 -234
- package/build/cjs/core/debug-id-upload.js.map +1 -1
- package/build/cjs/core/get-code-injection-position.js +59 -74
- package/build/cjs/core/get-code-injection-position.js.map +1 -1
- package/build/cjs/core/glob.js +9 -7
- package/build/cjs/core/glob.js.map +1 -1
- package/build/cjs/core/index.js +77 -61
- package/build/cjs/core/index.js.map +1 -1
- package/build/cjs/core/logger.js +17 -26
- package/build/cjs/core/logger.js.map +1 -1
- package/build/cjs/core/options-mapping.js +95 -117
- package/build/cjs/core/options-mapping.js.map +1 -1
- package/build/cjs/core/sentry/telemetry.js +90 -105
- package/build/cjs/core/sentry/telemetry.js.map +1 -1
- package/build/cjs/core/sentry/transports.js +92 -99
- package/build/cjs/core/sentry/transports.js.map +1 -1
- package/build/cjs/core/sourcemap-settings.js +98 -61
- package/build/cjs/core/sourcemap-settings.js.map +1 -1
- package/build/cjs/core/upload-filter.js +41 -46
- package/build/cjs/core/upload-filter.js.map +1 -1
- package/build/cjs/core/utils.js +228 -221
- package/build/cjs/core/utils.js.map +1 -1
- package/build/cjs/core/version.js +4 -5
- package/build/cjs/core/version.js.map +1 -1
- package/build/cjs/esbuild/index.js +183 -213
- package/build/cjs/esbuild/index.js.map +1 -1
- package/build/cjs/loader-utils/index.js +5 -10
- package/build/cjs/rollup/debug-id-injection.js +22 -38
- package/build/cjs/rollup/debug-id-injection.js.map +1 -1
- package/build/cjs/rollup/debug-id-stamping.js +14 -24
- package/build/cjs/rollup/debug-id-stamping.js.map +1 -1
- package/build/cjs/rollup/index.js +192 -246
- package/build/cjs/rollup/index.js.map +1 -1
- package/build/cjs/rollup/source-map-handling.js +151 -175
- package/build/cjs/rollup/source-map-handling.js.map +1 -1
- package/build/cjs/vite/index.js +19 -21
- package/build/cjs/vite/index.js.map +1 -1
- package/build/cjs/vite/source-map-hooks.js +112 -89
- package/build/cjs/vite/source-map-hooks.js.map +1 -1
- package/build/cjs/webpack/component-annotation-transform.js +20 -26
- package/build/cjs/webpack/component-annotation-transform.js.map +1 -1
- package/build/cjs/webpack/index.js +271 -340
- package/build/cjs/webpack/index.js.map +1 -1
- package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/assertClassBrand.js +6 -0
- package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/checkPrivateRedeclaration.js +5 -0
- package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldGet2.js +6 -0
- package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldInitSpec.js +6 -0
- package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldSet2.js +6 -0
- package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateMethodInitSpec.js +6 -0
- package/build/esm/_virtual/_rolldown/runtime.js +2 -0
- package/build/esm/babel-plugin/component-annotation.js +13 -29
- package/build/esm/babel-plugin/component-annotation.js.map +1 -1
- package/build/esm/babel-plugin/constants.js +140 -120
- package/build/esm/babel-plugin/constants.js.map +1 -1
- package/build/esm/babel-plugin/experimental.js +204 -305
- package/build/esm/babel-plugin/experimental.js.map +1 -1
- package/build/esm/babel-plugin/index.js +311 -434
- package/build/esm/babel-plugin/index.js.map +1 -1
- package/build/esm/bun/index.js +76 -101
- package/build/esm/bun/index.js.map +1 -1
- package/build/esm/core/build-plugin-manager.js +621 -683
- package/build/esm/core/build-plugin-manager.js.map +1 -1
- package/build/esm/core/cli.js +134 -127
- package/build/esm/core/cli.js.map +1 -1
- package/build/esm/core/component-annotate-hooks.js +16 -25
- package/build/esm/core/component-annotate-hooks.js.map +1 -1
- package/build/esm/core/component-annotation-oxc-ast.js +9 -19
- package/build/esm/core/component-annotation-oxc-ast.js.map +1 -1
- package/build/esm/core/component-annotation-oxc-fragments.js +44 -72
- package/build/esm/core/component-annotation-oxc-fragments.js.map +1 -1
- package/build/esm/core/component-annotation-oxc-jsx.js +115 -154
- package/build/esm/core/component-annotation-oxc-jsx.js.map +1 -1
- package/build/esm/core/component-annotation-oxc-walk.js +61 -121
- package/build/esm/core/component-annotation-oxc-walk.js.map +1 -1
- package/build/esm/core/component-annotation-oxc.js +65 -96
- package/build/esm/core/component-annotation-oxc.js.map +1 -1
- package/build/esm/core/debug-id-upload.js +218 -213
- package/build/esm/core/debug-id-upload.js.map +1 -1
- package/build/esm/core/get-code-injection-position.js +59 -72
- package/build/esm/core/get-code-injection-position.js.map +1 -1
- package/build/esm/core/glob.js +9 -5
- package/build/esm/core/glob.js.map +1 -1
- package/build/esm/core/index.js +62 -47
- package/build/esm/core/index.js.map +1 -1
- package/build/esm/core/logger.js +17 -24
- package/build/esm/core/logger.js.map +1 -1
- package/build/esm/core/options-mapping.js +95 -115
- package/build/esm/core/options-mapping.js.map +1 -1
- package/build/esm/core/sentry/telemetry.js +89 -102
- package/build/esm/core/sentry/telemetry.js.map +1 -1
- package/build/esm/core/sentry/transports.js +90 -83
- package/build/esm/core/sentry/transports.js.map +1 -1
- package/build/esm/core/sourcemap-settings.js +96 -59
- package/build/esm/core/sourcemap-settings.js.map +1 -1
- package/build/esm/core/upload-filter.js +39 -30
- package/build/esm/core/upload-filter.js.map +1 -1
- package/build/esm/core/utils.js +221 -211
- package/build/esm/core/utils.js.map +1 -1
- package/build/esm/core/version.js +4 -3
- package/build/esm/core/version.js.map +1 -1
- package/build/esm/esbuild/index.js +179 -197
- package/build/esm/esbuild/index.js.map +1 -1
- package/build/esm/loader-utils/index.js +4 -3
- package/build/esm/package.json +1 -1
- package/build/esm/rollup/debug-id-injection.js +22 -36
- package/build/esm/rollup/debug-id-injection.js.map +1 -1
- package/build/esm/rollup/debug-id-stamping.js +14 -22
- package/build/esm/rollup/debug-id-stamping.js.map +1 -1
- package/build/esm/rollup/index.js +189 -226
- package/build/esm/rollup/index.js.map +1 -1
- package/build/esm/rollup/source-map-handling.js +149 -159
- package/build/esm/rollup/source-map-handling.js.map +1 -1
- package/build/esm/vite/index.js +19 -18
- package/build/esm/vite/index.js.map +1 -1
- package/build/esm/vite/source-map-hooks.js +109 -72
- package/build/esm/vite/source-map-hooks.js.map +1 -1
- package/build/esm/webpack/component-annotation-transform.js +17 -24
- package/build/esm/webpack/component-annotation-transform.js.map +1 -1
- package/build/esm/webpack/index.js +268 -322
- package/build/esm/webpack/index.js.map +1 -1
- package/build/types/core/build-plugin-manager.d.ts +16 -5
- package/build/types/core/build-plugin-manager.d.ts.map +1 -1
- package/build/types/core/cli.d.ts +6 -1
- package/build/types/core/cli.d.ts.map +1 -1
- package/build/types/core/debug-id-upload.d.ts +7 -4
- package/build/types/core/debug-id-upload.d.ts.map +1 -1
- package/build/types/core/index.d.ts +3 -3
- package/build/types/core/index.d.ts.map +1 -1
- package/build/types/core/options-mapping.d.ts +4 -3
- package/build/types/core/options-mapping.d.ts.map +1 -1
- package/build/types/core/sentry/telemetry.d.ts.map +1 -1
- package/build/types/core/sourcemap-settings.d.ts +10 -1
- package/build/types/core/sourcemap-settings.d.ts.map +1 -1
- package/build/types/core/types.d.ts +25 -1
- package/build/types/core/types.d.ts.map +1 -1
- package/build/types/core/utils.d.ts +4 -0
- package/build/types/core/utils.d.ts.map +1 -1
- package/build/types/core/version.d.ts +1 -1
- package/build/types/esbuild/index.d.ts +2 -2
- package/build/types/esbuild/index.d.ts.map +1 -1
- package/build/types/rollup/index.d.ts +2 -2
- package/build/types/rollup/index.d.ts.map +1 -1
- package/build/types/rollup/source-map-handling.d.ts.map +1 -1
- package/build/types/vite/index.d.ts +3 -3
- package/build/types/vite/index.d.ts.map +1 -1
- package/build/types/vite/source-map-hooks.d.ts.map +1 -1
- package/build/types/webpack/index.d.ts +7 -3
- package/build/types/webpack/index.d.ts.map +1 -1
- package/package.json +8 -15
- package/build/cjs/loader-utils/index.js.map +0 -1
- package/build/esm/loader-utils/index.js.map +0 -1
|
@@ -1,25 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { stampDebugId } from "../core/debug-id-upload.js";
|
|
2
|
+
import { isJsFile } from "../core/index.js";
|
|
3
|
+
// src/rollup/debug-id-stamping.ts
|
|
4
4
|
function stampDebugIds(bundle, updateChunkCode) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
if (updateChunkCode) {
|
|
16
|
-
output.code = stamped.bundleSource;
|
|
17
|
-
}
|
|
18
|
-
if (stamped.sourceMapSource !== void 0 && sourceMapAsset?.type === "asset") {
|
|
19
|
-
sourceMapAsset.source = stamped.sourceMapSource;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
5
|
+
for (const output of Object.values(bundle)) {
|
|
6
|
+
if (output.type !== "chunk" || !isJsFile(output.fileName)) continue;
|
|
7
|
+
const sourceMapAsset = bundle[output.sourcemapFileName ?? `${output.fileName}.map`];
|
|
8
|
+
const sourceMapSource = sourceMapAsset?.type === "asset" && typeof sourceMapAsset.source === "string" ? sourceMapAsset.source : void 0;
|
|
9
|
+
const stamped = stampDebugId(output.code, sourceMapSource);
|
|
10
|
+
if (!stamped) continue;
|
|
11
|
+
if (updateChunkCode) output.code = stamped.bundleSource;
|
|
12
|
+
if (stamped.sourceMapSource !== void 0 && sourceMapAsset?.type === "asset") sourceMapAsset.source = stamped.sourceMapSource;
|
|
13
|
+
}
|
|
22
14
|
}
|
|
23
|
-
|
|
24
15
|
export { stampDebugIds };
|
|
25
|
-
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=debug-id-stamping.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug-id-stamping.js","sources":["../../../src/rollup/debug-id-stamping.ts"],"sourcesContent":["import { isJsFile, stampDebugId } from '../core';\n\n// The subset of Rollup's `OutputBundle` the stamping hooks read.\nexport type OutputBundle = Record<\n string,\n | { type: 'chunk'; fileName: string; code: string; sourcemapFileName?: string | null }\n | { type: 'asset'; fileName: string; source: string | Uint8Array }\n>;\n\nexport function stampDebugIds(bundle: OutputBundle, updateChunkCode: boolean): 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' ? sourceMapAsset.source : undefined;\n\n const stamped = stampDebugId(output.code, sourceMapSource);\n if (!stamped) {\n continue;\n }\n\n if (updateChunkCode) {\n output.code = stamped.bundleSource;\n }\n if (stamped.sourceMapSource !== undefined && sourceMapAsset?.type === 'asset') {\n sourceMapAsset.source = stamped.sourceMapSource;\n }\n }\n}\n"],"
|
|
1
|
+
{"version":3,"file":"debug-id-stamping.js","names":[],"sources":["../../../src/rollup/debug-id-stamping.ts"],"sourcesContent":["import { isJsFile, stampDebugId } from '../core';\n\n// The subset of Rollup's `OutputBundle` the stamping hooks read.\nexport type OutputBundle = Record<\n string,\n | { type: 'chunk'; fileName: string; code: string; sourcemapFileName?: string | null }\n | { type: 'asset'; fileName: string; source: string | Uint8Array }\n>;\n\nexport function stampDebugIds(bundle: OutputBundle, updateChunkCode: boolean): 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' ? sourceMapAsset.source : undefined;\n\n const stamped = stampDebugId(output.code, sourceMapSource);\n if (!stamped) {\n continue;\n }\n\n if (updateChunkCode) {\n output.code = stamped.bundleSource;\n }\n if (stamped.sourceMapSource !== undefined && sourceMapAsset?.type === 'asset') {\n sourceMapAsset.source = stamped.sourceMapSource;\n }\n }\n}\n"],"mappings":";;;AASA,SAAgB,cAAc,QAAsB,iBAAgC;CAClF,KAAK,MAAM,UAAU,OAAO,OAAO,MAAM,GAAG;EAC1C,IAAI,OAAO,SAAS,WAAW,CAAC,SAAS,OAAO,QAAQ,GACtD;EAGF,MAAM,iBAAiB,OAAO,OAAO,qBAAqB,GAAG,OAAO,SAAS;EAC7E,MAAM,kBACJ,gBAAgB,SAAS,WAAW,OAAO,eAAe,WAAW,WAAW,eAAe,SAAS,KAAA;EAE1G,MAAM,UAAU,aAAa,OAAO,MAAM,eAAe;EACzD,IAAI,CAAC,SACH;EAGF,IAAI,iBACF,OAAO,OAAO,QAAQ;EAExB,IAAI,QAAQ,oBAAoB,KAAA,KAAa,gBAAgB,SAAS,SACpE,eAAe,SAAS,QAAQ;CAEpC;AACF"}
|
|
@@ -1,239 +1,202 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
|
|
1
|
+
import "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { CodeInjection, generateModuleMetadataInjectorCode, generateReleaseInjectorCode, replaceBooleanFlagsInCode } from "../core/utils.js";
|
|
3
|
+
import { globFiles } from "../core/glob.js";
|
|
4
|
+
import { getCodeInjectionPosition } from "../core/get-code-injection-position.js";
|
|
5
|
+
import { createComponentNameAnnotateHooks } from "../core/component-annotate-hooks.js";
|
|
6
|
+
import { createDebugIdUploadFunction } from "../core/debug-id-upload.js";
|
|
7
|
+
import { createSentryBuildPluginManager } from "../core/build-plugin-manager.js";
|
|
8
|
+
import { getDebugIdSnippet, isInitialChunk, isJsFile, shouldSkipCodeInjection } from "../core/index.js";
|
|
9
|
+
import { finalizeRolldownDebugIds, getDebugIdForChunk, hasExistingDebugID } from "./debug-id-injection.js";
|
|
10
|
+
import { stampDebugIds } from "./debug-id-stamping.js";
|
|
11
|
+
import { createSourceMapHandling } from "./source-map-handling.js";
|
|
12
|
+
import { createViteSourceMapHooks } from "../vite/source-map-hooks.js";
|
|
13
|
+
import { createRequire } from "node:module";
|
|
14
|
+
import MagicString from "magic-string";
|
|
15
|
+
import * as path from "node:path";
|
|
16
|
+
// src/rollup/index.ts
|
|
16
17
|
let viteParseAstAsyncPromise;
|
|
17
18
|
const JS_MODULE_ID_FILTER = /\.[cm]?[jt]sx?(?:[?#].*)?$/;
|
|
18
19
|
function getRollupMajorVersion() {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return rollup.VERSION?.split(".")[0];
|
|
23
|
-
} catch {
|
|
24
|
-
}
|
|
25
|
-
return void 0;
|
|
20
|
+
try {
|
|
21
|
+
return createRequire(import.meta.url)("rollup").VERSION?.split(".")[0];
|
|
22
|
+
} catch {}
|
|
26
23
|
}
|
|
27
24
|
function getViteParseAstAsync() {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return viteModule.parseAstAsync;
|
|
40
|
-
}).catch(() => null);
|
|
41
|
-
}
|
|
42
|
-
return viteParseAstAsyncPromise;
|
|
25
|
+
if (!viteParseAstAsyncPromise) viteParseAstAsyncPromise = Promise.resolve().then(async () => {
|
|
26
|
+
const viteModule = createRequire(import.meta.url)("vite");
|
|
27
|
+
if (typeof viteModule.parseAstAsync !== "function") return null;
|
|
28
|
+
try {
|
|
29
|
+
await viteModule.parseAstAsync("const x = <div />;", { lang: "tsx" });
|
|
30
|
+
} catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return viteModule.parseAstAsync;
|
|
34
|
+
}).catch(() => null);
|
|
35
|
+
return viteParseAstAsyncPromise;
|
|
43
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* @ignore - internal plugin factory shared by the Rollup and Vite plugins.
|
|
39
|
+
*
|
|
40
|
+
* `main` carries injection, release creation and the upload. `post` runs last in `generateBundle`,
|
|
41
|
+
* copies chunks and their source maps into the upload staging folder and drops the map assets
|
|
42
|
+
* from the bundle, so the bundler never writes them.
|
|
43
|
+
*/
|
|
44
44
|
function _createRollupPluginInternals(userOptions = {}, buildTool, buildToolMajorVersion) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (!stagingHandedOver) {
|
|
190
|
-
await staging?.keep("The source map upload did not run.");
|
|
191
|
-
}
|
|
192
|
-
throw e;
|
|
193
|
-
} finally {
|
|
194
|
-
freeGlobalDependencyOnBuildArtifacts();
|
|
195
|
-
await sentryBuildPluginManager.deleteArtifacts();
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
const name = `sentry-${buildTool}-plugin`;
|
|
199
|
-
const transformHook = buildTool === "vite" ? {
|
|
200
|
-
filter: { id: JS_MODULE_ID_FILTER },
|
|
201
|
-
handler: transform
|
|
202
|
-
} : transform;
|
|
203
|
-
const viteSourceMapHooks = buildTool === "vite" ? createViteSourceMapHooks(sentryBuildPluginManager, sourceMapHandling) : void 0;
|
|
204
|
-
const main = {
|
|
205
|
-
name,
|
|
206
|
-
buildStart,
|
|
207
|
-
...shouldTransform ? { transform: transformHook } : {},
|
|
208
|
-
...viteSourceMapHooks ? { configResolved: viteSourceMapHooks.configResolved } : { outputOptions: sourceMapHandling.outputOptions },
|
|
209
|
-
renderChunk,
|
|
210
|
-
generateBundle: { order: "pre", handler: generateBundle },
|
|
211
|
-
writeBundle
|
|
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 };
|
|
45
|
+
const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {
|
|
46
|
+
loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[sentry-${buildTool}-plugin]`,
|
|
47
|
+
buildTool,
|
|
48
|
+
buildToolMajorVersion: buildToolMajorVersion || getRollupMajorVersion()
|
|
49
|
+
});
|
|
50
|
+
const { logger, normalizedOptions: options, bundleSizeOptimizationReplacementValues: replacementValues, bundleMetadata, createDependencyOnBuildArtifacts } = sentryBuildPluginManager;
|
|
51
|
+
if (options.disable) return {
|
|
52
|
+
main: { name: "sentry-noop-plugin" },
|
|
53
|
+
post: void 0
|
|
54
|
+
};
|
|
55
|
+
if (process.cwd().match(/\\node_modules\\|\/node_modules\//)) logger.warn("Running Sentry plugin from within a `node_modules` folder. Some features may not work.");
|
|
56
|
+
const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
|
|
57
|
+
const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });
|
|
58
|
+
const sourcemapsEnabled = options.sourcemaps?.disable !== true;
|
|
59
|
+
const sourceMapHandling = createSourceMapHandling(sentryBuildPluginManager);
|
|
60
|
+
const releaseInjectionCode = new CodeInjection();
|
|
61
|
+
const chunkInjectionCode = new CodeInjection();
|
|
62
|
+
if (!options.release.inject) logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
|
|
63
|
+
else if (!options.release.name) logger.debug("No release name provided. Will not inject release. Please set the `release.name` option to identify your release.");
|
|
64
|
+
else releaseInjectionCode.append(generateReleaseInjectorCode({
|
|
65
|
+
release: options.release.name,
|
|
66
|
+
injectBuildInformation: options._experiments.injectBuildInformation || false
|
|
67
|
+
}));
|
|
68
|
+
if (Object.keys(bundleMetadata).length > 0) chunkInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));
|
|
69
|
+
const transformAnnotations = options.reactComponentAnnotation?.enabled ? createComponentNameAnnotateHooks(options.reactComponentAnnotation?.ignoredComponents || [], !!options.reactComponentAnnotation?._experimentalInjectIntoHtml, {
|
|
70
|
+
getParseAstAsync: buildTool === "vite" && buildToolMajorVersion === "8" ? getViteParseAstAsync : void 0,
|
|
71
|
+
logger
|
|
72
|
+
}) : void 0;
|
|
73
|
+
const transformReplace = Object.keys(replacementValues).length > 0;
|
|
74
|
+
const shouldTransform = transformAnnotations || transformReplace;
|
|
75
|
+
function buildStart() {
|
|
76
|
+
sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {});
|
|
77
|
+
}
|
|
78
|
+
async function transform(code, id, meta) {
|
|
79
|
+
if (transformAnnotations) {
|
|
80
|
+
const result = await transformAnnotations.transform(code, id, meta);
|
|
81
|
+
if (result) return result;
|
|
82
|
+
}
|
|
83
|
+
if (transformReplace) return replaceBooleanFlagsInCode(code, replacementValues);
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
function renderChunk(code, chunk, _, meta) {
|
|
87
|
+
if (!isJsFile(chunk.fileName)) return null;
|
|
88
|
+
if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) return null;
|
|
89
|
+
const injectCode = new CodeInjection();
|
|
90
|
+
if (isInitialChunk(chunk, meta?.chunks)) injectCode.append(releaseInjectionCode);
|
|
91
|
+
injectCode.append(chunkInjectionCode);
|
|
92
|
+
if (sourcemapsEnabled && !hasExistingDebugID(code)) {
|
|
93
|
+
const debugId = getDebugIdForChunk(code, !!this?.meta?.rolldownVersion);
|
|
94
|
+
injectCode.append(getDebugIdSnippet(debugId));
|
|
95
|
+
}
|
|
96
|
+
if (injectCode.isEmpty()) return null;
|
|
97
|
+
const ms = meta?.magicString || new MagicString(code, { filename: chunk.fileName });
|
|
98
|
+
const injectionPosition = getCodeInjectionPosition(code);
|
|
99
|
+
const codeToInject = injectionPosition === code.length ? `\n${injectCode.code()}` : injectCode.code();
|
|
100
|
+
ms.appendLeft(injectionPosition, codeToInject);
|
|
101
|
+
if (ms?.constructor?.name === "BindingMagicString") return { code: ms };
|
|
102
|
+
return {
|
|
103
|
+
code: ms.toString(),
|
|
104
|
+
map: ms.generateMap({
|
|
105
|
+
file: chunk.fileName,
|
|
106
|
+
hires: "boundary"
|
|
107
|
+
})
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Resolves Rolldown's placeholder debug IDs, then stamps debug IDs into the emitted chunks and
|
|
112
|
+
* source maps.
|
|
113
|
+
*
|
|
114
|
+
* `disable-upload` skips the upload routine (which stamps debug IDs into temp copies), so the emitted
|
|
115
|
+
* artifacts get stamped here instead. Not in `renderChunk`: minifiers running after it would strip the
|
|
116
|
+
* comment. Rollup computes `[hash]` file names before this hook, so only plugins that hash the final
|
|
117
|
+
* assets afterwards (e.g. subresource integrity) see the stamped content.
|
|
118
|
+
*/
|
|
119
|
+
function generateBundle(_outputOptions, bundle) {
|
|
120
|
+
if (this?.meta?.rolldownVersion) finalizeRolldownDebugIds(bundle);
|
|
121
|
+
if (options.sourcemaps?.disable !== "disable-upload") return;
|
|
122
|
+
stampDebugIds(bundle, true);
|
|
123
|
+
}
|
|
124
|
+
async function writeBundle(outputOptions, bundle) {
|
|
125
|
+
const staging = await sourceMapHandling.takeStaging(outputOptions, bundle);
|
|
126
|
+
let stagingHandedOver = false;
|
|
127
|
+
try {
|
|
128
|
+
await sentryBuildPluginManager.createRelease();
|
|
129
|
+
if (sourcemapsEnabled && options.sourcemaps?.disable !== "disable-upload") {
|
|
130
|
+
let buildArtifacts;
|
|
131
|
+
if (outputOptions.dir) {
|
|
132
|
+
const outputDir = outputOptions.dir;
|
|
133
|
+
const JS_AND_MAP_PATTERNS = [
|
|
134
|
+
"/**/*.js",
|
|
135
|
+
"/**/*.mjs",
|
|
136
|
+
"/**/*.cjs",
|
|
137
|
+
"/**/*.js.map",
|
|
138
|
+
"/**/*.mjs.map",
|
|
139
|
+
"/**/*.cjs.map"
|
|
140
|
+
].map((q) => `${q}?(\\?*)?(#*)`);
|
|
141
|
+
buildArtifacts = await globFiles(JS_AND_MAP_PATTERNS, { root: outputDir });
|
|
142
|
+
} else if (outputOptions.file) buildArtifacts = [outputOptions.file];
|
|
143
|
+
else buildArtifacts = Object.keys(bundle ?? {}).map((asset) => path.join(path.resolve(), asset));
|
|
144
|
+
stagingHandedOver = true;
|
|
145
|
+
await upload(buildArtifacts, { staging });
|
|
146
|
+
} else {
|
|
147
|
+
stagingHandedOver = true;
|
|
148
|
+
await staging?.discard();
|
|
149
|
+
}
|
|
150
|
+
} catch (e) {
|
|
151
|
+
if (!stagingHandedOver) await staging?.keep("The source map upload did not run.");
|
|
152
|
+
throw e;
|
|
153
|
+
} finally {
|
|
154
|
+
freeGlobalDependencyOnBuildArtifacts();
|
|
155
|
+
await sentryBuildPluginManager.deleteArtifacts();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const name = `sentry-${buildTool}-plugin`;
|
|
159
|
+
const transformHook = buildTool === "vite" ? {
|
|
160
|
+
filter: { id: JS_MODULE_ID_FILTER },
|
|
161
|
+
handler: transform
|
|
162
|
+
} : transform;
|
|
163
|
+
const viteSourceMapHooks = buildTool === "vite" ? createViteSourceMapHooks(sentryBuildPluginManager, sourceMapHandling) : void 0;
|
|
164
|
+
return {
|
|
165
|
+
main: {
|
|
166
|
+
name,
|
|
167
|
+
buildStart,
|
|
168
|
+
...shouldTransform ? { transform: transformHook } : {},
|
|
169
|
+
...viteSourceMapHooks ? { configResolved: viteSourceMapHooks.configResolved } : { outputOptions: sourceMapHandling.outputOptions },
|
|
170
|
+
renderChunk,
|
|
171
|
+
generateBundle: {
|
|
172
|
+
order: "pre",
|
|
173
|
+
handler: generateBundle
|
|
174
|
+
},
|
|
175
|
+
writeBundle
|
|
176
|
+
},
|
|
177
|
+
post: {
|
|
178
|
+
name: buildTool === "vite" ? "sentry-vite-upload-staging" : "sentry-rollup-upload-staging",
|
|
179
|
+
...viteSourceMapHooks ? { config: viteSourceMapHooks.config } : {},
|
|
180
|
+
generateBundle: {
|
|
181
|
+
order: "post",
|
|
182
|
+
async handler(outputOptions, bundle, isWrite) {
|
|
183
|
+
if (buildTool === "vite" && options.sourcemaps?.disable === "disable-upload") stampDebugIds(bundle, false);
|
|
184
|
+
await sourceMapHandling.stageSourceMaps(outputOptions, bundle, isWrite);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
};
|
|
229
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* @ignore - this is the internal plugin factory function only used for the Vite plugin!
|
|
192
|
+
*/
|
|
230
193
|
function _rollupPluginInternal(userOptions = {}, buildTool, buildToolMajorVersion) {
|
|
231
|
-
|
|
194
|
+
return _createRollupPluginInternals(userOptions, buildTool, buildToolMajorVersion).main;
|
|
232
195
|
}
|
|
233
196
|
function sentryRollupPlugin(userOptions = {}) {
|
|
234
|
-
|
|
235
|
-
|
|
197
|
+
const { main, post } = _createRollupPluginInternals(userOptions, "rollup");
|
|
198
|
+
return post ? [main, post] : [main];
|
|
236
199
|
}
|
|
237
|
-
|
|
238
200
|
export { _createRollupPluginInternals, _rollupPluginInternal, sentryRollupPlugin };
|
|
239
|
-
|
|
201
|
+
|
|
202
|
+
//# 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';\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,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EACA;AACA,EAAA,OAAO,4BAAA,CAA6B,WAAA,EAAa,SAAA,EAAW,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;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/rollup/index.ts"],"sourcesContent":["import type { ChunkGraphNode, InternalOptions, 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: InternalOptions = {},\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}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