@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,183 +1,173 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { isJsFile } from "../core/index.js";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
// src/rollup/source-map-handling.ts
|
|
4
|
+
/** Maps Rollup's (and Vite's) `sourcemap` setting onto the plugin's source map kinds. */
|
|
4
5
|
function sourceMapKindFromRollupSetting(setting) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return "visible";
|
|
12
|
-
default:
|
|
13
|
-
return setting;
|
|
14
|
-
}
|
|
6
|
+
switch (setting) {
|
|
7
|
+
case void 0: return "unset";
|
|
8
|
+
case false: return "off";
|
|
9
|
+
case true: return "visible";
|
|
10
|
+
default: return setting;
|
|
11
|
+
}
|
|
15
12
|
}
|
|
13
|
+
/** The directory an output writes to. Decisions and stagings are keyed by it. */
|
|
16
14
|
function getOutputDestination(outputOptions) {
|
|
17
|
-
|
|
15
|
+
return path.resolve(outputOptions.dir ?? path.dirname(outputOptions.file ?? "."));
|
|
18
16
|
}
|
|
19
17
|
const MATCH_KEYS = [
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
"dir",
|
|
19
|
+
"file",
|
|
20
|
+
"format",
|
|
21
|
+
"entryFileNames",
|
|
22
|
+
"chunkFileNames",
|
|
23
|
+
"preserveModules",
|
|
24
|
+
"sourcemap"
|
|
27
25
|
];
|
|
26
|
+
/** The raw options accept aliases that the normalized options do not carry. */
|
|
28
27
|
function normalizeFormat(format) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return "system";
|
|
37
|
-
default:
|
|
38
|
-
return format;
|
|
39
|
-
}
|
|
28
|
+
switch (format) {
|
|
29
|
+
case "esm":
|
|
30
|
+
case "module": return "es";
|
|
31
|
+
case "commonjs": return "cjs";
|
|
32
|
+
case "systemjs": return "system";
|
|
33
|
+
default: return format;
|
|
34
|
+
}
|
|
40
35
|
}
|
|
36
|
+
/** The fields of `OutputMatch` an output sets, in the form the normalized options carry them. */
|
|
41
37
|
function getOutputMatch(outputOptions) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
return match;
|
|
38
|
+
const match = {};
|
|
39
|
+
for (const key of MATCH_KEYS) {
|
|
40
|
+
const value = outputOptions[key];
|
|
41
|
+
if (value === void 0) continue;
|
|
42
|
+
match[key] = key === "format" ? normalizeFormat(value) : key === "dir" || key === "file" ? path.resolve(String(value)) : value;
|
|
43
|
+
}
|
|
44
|
+
return match;
|
|
51
45
|
}
|
|
52
46
|
function matchesOutput(match, outputOptions) {
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
const actual = getOutputMatch(outputOptions);
|
|
48
|
+
return MATCH_KEYS.every((key) => match[key] === void 0 || match[key] === actual[key]);
|
|
55
49
|
}
|
|
56
50
|
function isSameMatch(a, b) {
|
|
57
|
-
|
|
51
|
+
return MATCH_KEYS.every((key) => a[key] === b[key]);
|
|
58
52
|
}
|
|
59
53
|
function countMatchFields(match) {
|
|
60
|
-
|
|
54
|
+
return MATCH_KEYS.filter((key) => match[key] !== void 0).length;
|
|
61
55
|
}
|
|
62
56
|
const DEBUG_ID_PATTERN = /sentry-dbid-([0-9a-f-]{36})|\/\/# debugId=([0-9a-f-]{36})/i;
|
|
57
|
+
/** Identifies the chunks of a bundle by name and debug ID, so a staging can be matched to its write. */
|
|
63
58
|
function getBundleSignature(bundle) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
return entries.sort().join("\n");
|
|
59
|
+
const entries = [];
|
|
60
|
+
for (const output of Object.values(bundle)) if (output.type === "chunk" && isJsFile(output.fileName)) {
|
|
61
|
+
const match = output.code.match(DEBUG_ID_PATTERN);
|
|
62
|
+
entries.push(`${output.fileName}:${match?.[1] ?? match?.[2] ?? ""}`);
|
|
63
|
+
}
|
|
64
|
+
return entries.sort().join("\n");
|
|
72
65
|
}
|
|
73
66
|
function getSourceMapFileName(output) {
|
|
74
|
-
|
|
67
|
+
return output.sourcemapFileName ?? `${output.fileName}.map`;
|
|
75
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Source map decisions and upload stagings of one plugin instance. Keyed by output destination
|
|
71
|
+
* because one instance can serve several outputs, and watch mode or several `write()` calls
|
|
72
|
+
* rebuild the same one. Outputs that share a directory are told apart by `OutputMatch`.
|
|
73
|
+
*/
|
|
76
74
|
function createSourceMapHandling(sentryBuildPluginManager) {
|
|
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
|
-
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
|
-
};
|
|
75
|
+
const decisions = /* @__PURE__ */ new Map();
|
|
76
|
+
const pendingStagings = /* @__PURE__ */ new Map();
|
|
77
|
+
function setDecision(destination, record) {
|
|
78
|
+
const records = decisions.get(destination) ?? [];
|
|
79
|
+
const index = records.findIndex((existing) => isSameMatch(existing.match, record.match));
|
|
80
|
+
if (index === -1) records.push(record);
|
|
81
|
+
else records[index] = record;
|
|
82
|
+
decisions.set(destination, records);
|
|
83
|
+
}
|
|
84
|
+
function findDecision(destination, outputOptions) {
|
|
85
|
+
return (decisions.get(destination) ?? []).filter((record) => matchesOutput(record.match, outputOptions)).sort((a, b) => countMatchFields(b.match) - countMatchFields(a.match))[0];
|
|
86
|
+
}
|
|
87
|
+
function dropSourceMaps(bundle, shouldDrop = () => true) {
|
|
88
|
+
for (const output of Object.values(bundle)) if (output.type === "chunk" && isJsFile(output.fileName) && shouldDrop(output.fileName)) delete bundle[getSourceMapFileName(output)];
|
|
89
|
+
}
|
|
90
|
+
function dropAssetSourceMaps(bundle) {
|
|
91
|
+
const chunkMaps = /* @__PURE__ */ new Set();
|
|
92
|
+
for (const output of Object.values(bundle)) if (output.type === "chunk") chunkMaps.add(getSourceMapFileName(output));
|
|
93
|
+
for (const [fileName, output] of Object.entries(bundle)) if (output.type === "asset" && fileName.endsWith(".map") && !chunkMaps.has(fileName)) delete bundle[fileName];
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
outputOptions: (rawOutputOptions) => {
|
|
97
|
+
const kind = sourceMapKindFromRollupSetting(rawOutputOptions.sourcemap);
|
|
98
|
+
const decision = sentryBuildPluginManager.sourceMaps.decide(kind, { log: false });
|
|
99
|
+
const outputOptions = decision.enableHidden ? {
|
|
100
|
+
...rawOutputOptions,
|
|
101
|
+
sourcemap: "hidden"
|
|
102
|
+
} : rawOutputOptions;
|
|
103
|
+
setDecision(getOutputDestination(rawOutputOptions), {
|
|
104
|
+
match: getOutputMatch(outputOptions),
|
|
105
|
+
kind,
|
|
106
|
+
decision
|
|
107
|
+
});
|
|
108
|
+
return decision.enableHidden ? outputOptions : null;
|
|
109
|
+
},
|
|
110
|
+
setDecision,
|
|
111
|
+
stageSourceMaps: async (outputOptions, bundle, isWrite) => {
|
|
112
|
+
const destination = getOutputDestination(outputOptions);
|
|
113
|
+
const record = findDecision(destination, outputOptions);
|
|
114
|
+
if (!record) return;
|
|
115
|
+
if (isWrite === false) {
|
|
116
|
+
if (record.kind === "unset" && record.decision.enableHidden) dropSourceMaps(bundle);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
sentryBuildPluginManager.sourceMaps.logDecision(record.decision);
|
|
120
|
+
if (!record.decision.deleteAfterUpload) return;
|
|
121
|
+
const removeAll = record.decision.removeAllSourceMaps === true;
|
|
122
|
+
if (removeAll && record.kind !== "unset") dropAssetSourceMaps(bundle);
|
|
123
|
+
if (!sentryBuildPluginManager.sourceMaps.uploadPossible) {
|
|
124
|
+
dropSourceMaps(bundle, removeAll ? void 0 : (fileName) => sentryBuildPluginManager.sourceMaps.shouldUpload(path.join(destination, fileName)));
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const staging = await sentryBuildPluginManager.createUploadStaging();
|
|
128
|
+
try {
|
|
129
|
+
for (const output of Object.values(bundle)) {
|
|
130
|
+
if (output.type !== "chunk" || !isJsFile(output.fileName)) continue;
|
|
131
|
+
const mapFileName = getSourceMapFileName(output);
|
|
132
|
+
const mapAsset = bundle[mapFileName];
|
|
133
|
+
if (mapAsset?.type !== "asset" || typeof mapAsset.source !== "string") continue;
|
|
134
|
+
const result = await staging.stage({
|
|
135
|
+
code: output.code,
|
|
136
|
+
mapSource: mapAsset.source,
|
|
137
|
+
mapDir: path.join(destination, path.dirname(mapFileName)),
|
|
138
|
+
chunkPath: path.join(destination, output.fileName)
|
|
139
|
+
});
|
|
140
|
+
if (result === "staged" || removeAll) delete bundle[mapFileName];
|
|
141
|
+
if (result === "skipped" || result === "failed") sentryBuildPluginManager.logger.warn(removeAll ? `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.`);
|
|
142
|
+
}
|
|
143
|
+
} catch (e) {
|
|
144
|
+
await staging.discard();
|
|
145
|
+
throw e;
|
|
146
|
+
}
|
|
147
|
+
const stagings = pendingStagings.get(destination) ?? [];
|
|
148
|
+
pendingStagings.set(destination, stagings);
|
|
149
|
+
const superseded = stagings.filter((pending) => isSameMatch(pending.match, record.match));
|
|
150
|
+
for (const pending of superseded) stagings.splice(stagings.indexOf(pending), 1);
|
|
151
|
+
stagings.push({
|
|
152
|
+
staging,
|
|
153
|
+
signature: getBundleSignature(bundle),
|
|
154
|
+
match: record.match
|
|
155
|
+
});
|
|
156
|
+
for (const pending of superseded) {
|
|
157
|
+
sentryBuildPluginManager.logger.debug(`Discarding staged source maps of an earlier build of ${destination} that was never written.`);
|
|
158
|
+
await pending.staging.discard();
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
takeStaging: async (outputOptions, bundle) => {
|
|
162
|
+
const destination = getOutputDestination(outputOptions);
|
|
163
|
+
const stagings = pendingStagings.get(destination) ?? [];
|
|
164
|
+
if (!bundle) return stagings.shift()?.staging;
|
|
165
|
+
const signature = getBundleSignature(bundle);
|
|
166
|
+
const index = stagings.findIndex((pending) => pending.signature === signature);
|
|
167
|
+
return index === -1 ? void 0 : stagings.splice(index, 1)[0]?.staging;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
180
170
|
}
|
|
181
|
-
|
|
182
171
|
export { createSourceMapHandling, getOutputDestination, getOutputMatch, sourceMapKindFromRollupSetting };
|
|
183
|
-
|
|
172
|
+
|
|
173
|
+
//# sourceMappingURL=source-map-handling.js.map
|
|
@@ -1 +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":";;;A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AAgB,GAAA,CAAI,WAAW,KAAK,EAAC;AAEtD,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;;;;"}
|
|
1
|
+
{"version":3,"file":"source-map-handling.js","names":[],"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, shouldDrop: (fileName: string) => boolean = () => true): void {\n for (const output of Object.values(bundle)) {\n if (output.type === 'chunk' && isJsFile(output.fileName) && shouldDrop(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 // Other plugins emit maps as assets, e.g. for CSS or for Vite worker\n // bundles. Chunk maps stay here, because staging still needs them.\n function dropAssetSourceMaps(bundle: OutputBundle): void {\n const chunkMaps = new Set<string>();\n for (const output of Object.values(bundle)) {\n if (output.type === 'chunk') {\n chunkMaps.add(getSourceMapFileName(output));\n }\n }\n for (const [fileName, output] of Object.entries(bundle)) {\n if (output.type === 'asset' && fileName.endsWith('.map') && !chunkMaps.has(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[fileName];\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 removeAll = record.decision.removeAllSourceMaps === true;\n // With `unset` the plugin only turned on the chunk maps. Asset maps\n // come from other plugins' own settings.\n if (removeAll && record.kind !== 'unset') {\n dropAssetSourceMaps(bundle);\n }\n\n if (!sentryBuildPluginManager.sourceMaps.uploadPossible) {\n dropSourceMaps(\n bundle,\n removeAll\n ? undefined\n : fileName => sentryBuildPluginManager.sourceMaps.shouldUpload(path.join(destination, fileName)),\n );\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 or the SDK turned on never reaches the output,\n // whether or not the chunk is uploaded. A map the user enabled\n // stays unless it was staged.\n if (result === 'staged' || removeAll) {\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 removeAll\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"],"mappings":";;;;AA4BA,SAAgB,+BAA+B,SAAgD;CAC7F,QAAQ,SAAR;EACE,KAAK,KAAA,GACH,OAAO;EACT,KAAK,OACH,OAAO;EACT,KAAK,MACH,OAAO;EACT,SACE,OAAO;CACX;AACF;;AAGA,SAAgB,qBAAqB,eAAiD;CACpF,OAAO,KAAK,QAAQ,cAAc,OAAO,KAAK,QAAQ,cAAc,QAAQ,GAAG,CAAC;AAClF;AAEA,MAAM,aAAa;CACjB;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,SAAS,gBAAgB,QAA0B;CACjD,QAAQ,QAAR;EACE,KAAK;EACL,KAAK,UACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,SACE,OAAO;CACX;AACF;;AAGA,SAAgB,eAAe,eAAyC;CACtE,MAAM,QAAqB,CAAC;CAC5B,KAAK,MAAM,OAAO,YAAY;EAC5B,MAAM,QAAQ,cAAc;EAC5B,IAAI,UAAU,KAAA,GACZ;EAEF,MAAM,OACJ,QAAQ,WAAW,gBAAgB,KAAK,IAAI,QAAQ,SAAS,QAAQ,SAAS,KAAK,QAAQ,OAAO,KAAK,CAAC,IAAI;CAChH;CACA,OAAO;AACT;AAEA,SAAS,cAAc,OAAoB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,OAAO,GAAG,CAAC;GAE9C,SAAS,KAAK;IAAE;IAAS,WAAW,mBAAmB,MAAM;IAAG,OAAO,OAAO;GAAM,CAAC;GAErF,KAAK,MAAM,WAAW,YAAY;IAChC,yBAAyB,OAAO,MAC9B,wDAAwD,YAAY,yBACtE;IACA,MAAM,QAAQ,QAAQ,QAAQ;GAChC;EACF;EAEA,aAAa,OAAO,eAAe,WAAW;GAC5C,MAAM,cAAc,qBAAqB,aAAa;GACtD,MAAM,WAAW,gBAAgB,IAAI,WAAW,KAAK,CAAC;GAEtD,IAAI,CAAC,QACH,OAAO,SAAS,MAAM,CAAC,EAAE;GAG3B,MAAM,YAAY,mBAAmB,MAAM;GAC3C,MAAM,QAAQ,SAAS,WAAU,YAAW,QAAQ,cAAc,SAAS;GAC3E,OAAO,UAAU,KAAK,KAAA,IAAY,SAAS,OAAO,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;EAClE;CACF;AACF"}
|
package/build/esm/vite/index.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { _createRollupPluginInternals } from "../rollup/index.js";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
// src/vite/index.ts
|
|
4
5
|
function getViteMajorVersion() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return vite.version?.split(".")[0];
|
|
9
|
-
} catch {
|
|
10
|
-
}
|
|
11
|
-
return void 0;
|
|
6
|
+
try {
|
|
7
|
+
return createRequire(import.meta.url)("vite").version?.split(".")[0];
|
|
8
|
+
} catch {}
|
|
12
9
|
}
|
|
13
10
|
const sentryVitePlugin = (options) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
const { main, post } = _createRollupPluginInternals(options, "vite", getViteMajorVersion());
|
|
12
|
+
const plugins = [{
|
|
13
|
+
enforce: "pre",
|
|
14
|
+
...main
|
|
15
|
+
}];
|
|
16
|
+
if (post) plugins.push({
|
|
17
|
+
enforce: "post",
|
|
18
|
+
...post
|
|
19
|
+
});
|
|
20
|
+
return plugins;
|
|
20
21
|
};
|
|
21
|
-
|
|
22
22
|
export { sentryVitePlugin };
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/vite/index.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/vite/index.ts"],"sourcesContent":["import type { InternalOptions } from '../core';\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?: InternalOptions): 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, InternalOptions as SentryVitePluginInternalOptions } from '../core';\n"],"mappings":";;;;AAUA,SAAS,sBAA0C;CACjD,IAAI;EAKF,OAFY,cAAc,YAAY,GACvB,CAAC,CAAC,MACP,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,CAAC;CAClC,QAAQ,CAER;AAGF;AAEA,MAAa,oBAAoB,YAAkD;CACjF,MAAM,EAAE,MAAM,SAAS,6BAA6B,SAAS,QAAQ,oBAAoB,CAAC;CAE1F,MAAM,UAA8B,CAAC;EAAE,SAAS;EAAO,GAAG;CAAK,CAAC;CAEhE,IAAI,MACF,QAAQ,KAAK;EAAE,SAAS;EAAQ,GAAG;CAAK,CAAC;CAG3C,OAAO;AACT"}
|