@sentry/bundler-plugins 11.12.0 → 11.13.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 -219
- 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 +180 -211
- 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 -209
- 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 +176 -195
- 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,77 +1,114 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { getDeleteSourcemapsAfterUpload, getSdkEnabledSourceMaps } from "../core/sourcemap-settings.js";
|
|
2
|
+
import "../core/index.js";
|
|
3
|
+
import { getOutputMatch, sourceMapKindFromRollupSetting } from "../rollup/source-map-handling.js";
|
|
4
|
+
import * as path from "node:path";
|
|
5
|
+
// src/vite/source-map-hooks.ts
|
|
6
|
+
const NO_CHANGE = {
|
|
7
|
+
enableHidden: false,
|
|
8
|
+
deleteAfterUpload: false
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* The outputs an environment writes: one per entry of `rollupOptions.output` or
|
|
12
|
+
* `rolldownOptions.output`. An output writes to `build.outDir` (relative to the root) unless it
|
|
13
|
+
* sets its own `dir`, which the bundler resolves from the working directory. An output's own
|
|
14
|
+
* `sourcemap` overrides `build.sourcemap`.
|
|
15
|
+
*/
|
|
5
16
|
function getOutputs(root, build) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
const configured = build.rolldownOptions?.output ?? build.rollupOptions?.output;
|
|
18
|
+
return (Array.isArray(configured) ? configured : [configured ?? {}]).map((output) => {
|
|
19
|
+
const sourcemap = output.sourcemap ?? build.sourcemap;
|
|
20
|
+
return {
|
|
21
|
+
destination: output.dir === void 0 ? path.resolve(root, build.outDir ?? "dist") : path.resolve(output.dir),
|
|
22
|
+
match: getOutputMatch({
|
|
23
|
+
...output,
|
|
24
|
+
sourcemap
|
|
25
|
+
}),
|
|
26
|
+
sourcemap,
|
|
27
|
+
ownSetting: output.sourcemap !== void 0
|
|
28
|
+
};
|
|
29
|
+
});
|
|
17
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Vite warns about `rollupOptions.output.sourcemap`, so the Vite plugin decides on `build.sourcemap`
|
|
33
|
+
* in a `config` hook. The hook belongs on the post plugin: framework plugins that set
|
|
34
|
+
* `build.sourcemap` themselves run first, and the decision sees the merged setting. The output
|
|
35
|
+
* directories are only known in `configResolved`, which then records the decision for each of them.
|
|
36
|
+
*/
|
|
18
37
|
function createViteSourceMapHooks(sentryBuildPluginManager, sourceMapHandling) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
38
|
+
const decisions = /* @__PURE__ */ new Map();
|
|
39
|
+
return {
|
|
40
|
+
config: (userConfig, env) => {
|
|
41
|
+
if (env.command !== "build") return null;
|
|
42
|
+
decisions.clear();
|
|
43
|
+
const kind = sourceMapKindFromRollupSetting(userConfig.build?.sourcemap);
|
|
44
|
+
const decision = sentryBuildPluginManager.sourceMaps.decide(kind, { log: false });
|
|
45
|
+
decisions.set("*", {
|
|
46
|
+
kind,
|
|
47
|
+
decision
|
|
48
|
+
});
|
|
49
|
+
const result = decision.enableHidden ? { build: { sourcemap: "hidden" } } : {};
|
|
50
|
+
for (const [name, environment] of Object.entries(userConfig.environments ?? {})) {
|
|
51
|
+
const setting = environment?.build?.sourcemap;
|
|
52
|
+
if (setting === void 0) continue;
|
|
53
|
+
const environmentKind = sourceMapKindFromRollupSetting(setting);
|
|
54
|
+
const environmentDecision = sentryBuildPluginManager.sourceMaps.decide(environmentKind, {
|
|
55
|
+
log: false,
|
|
56
|
+
environment: name
|
|
57
|
+
});
|
|
58
|
+
decisions.set(name, {
|
|
59
|
+
kind: environmentKind,
|
|
60
|
+
decision: environmentDecision
|
|
61
|
+
});
|
|
62
|
+
if (environmentDecision.enableHidden) result.environments = {
|
|
63
|
+
...result.environments,
|
|
64
|
+
[name]: { build: { sourcemap: "hidden" } }
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
},
|
|
69
|
+
configResolved: (config) => {
|
|
70
|
+
const environments = config.environments ?? { client: { build: config.build } };
|
|
71
|
+
for (const [name, environment] of Object.entries(environments)) {
|
|
72
|
+
const { kind, decision } = decisions.get(name) ?? decisions.get("*") ?? {
|
|
73
|
+
kind: "unset",
|
|
74
|
+
decision: NO_CHANGE
|
|
75
|
+
};
|
|
76
|
+
const environmentName = decisions.has(name) ? name : void 0;
|
|
77
|
+
const { normalizedOptions } = sentryBuildPluginManager;
|
|
78
|
+
const deleteOption = getDeleteSourcemapsAfterUpload(normalizedOptions, environmentName);
|
|
79
|
+
const sdkEnabledSourceMaps = getSdkEnabledSourceMaps(normalizedOptions, environmentName);
|
|
80
|
+
for (const output of getOutputs(config.root, environment.build)) {
|
|
81
|
+
if (output.ownSetting) {
|
|
82
|
+
const outputKind = sourceMapKindFromRollupSetting(output.sourcemap);
|
|
83
|
+
const removeAllSourceMaps = sdkEnabledSourceMaps && (outputKind === "hidden" || outputKind === "visible");
|
|
84
|
+
sourceMapHandling.setDecision(output.destination, {
|
|
85
|
+
match: output.match,
|
|
86
|
+
kind: outputKind,
|
|
87
|
+
decision: {
|
|
88
|
+
enableHidden: false,
|
|
89
|
+
deleteAfterUpload: deleteOption === true && (outputKind === "hidden" || removeAllSourceMaps),
|
|
90
|
+
removeAllSourceMaps
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (decision.deleteAfterUpload && output.sourcemap !== "hidden") {
|
|
96
|
+
sentryBuildPluginManager.logger.debug(`Source maps of the "${name}" environment are set to ${JSON.stringify(output.sourcemap)}. Not removing them after upload.`);
|
|
97
|
+
sourceMapHandling.setDecision(output.destination, {
|
|
98
|
+
match: output.match,
|
|
99
|
+
kind,
|
|
100
|
+
decision: NO_CHANGE
|
|
101
|
+
});
|
|
102
|
+
} else sourceMapHandling.setDecision(output.destination, {
|
|
103
|
+
match: output.match,
|
|
104
|
+
kind,
|
|
105
|
+
decision
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
74
111
|
}
|
|
75
|
-
|
|
76
112
|
export { createViteSourceMapHooks };
|
|
77
|
-
|
|
113
|
+
|
|
114
|
+
//# sourceMappingURL=source-map-hooks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-map-hooks.js","sources":["../../../src/vite/source-map-hooks.ts"],"sourcesContent":["import * as path from 'node:path';\nimport type { SentryBuildPluginManager, SourceMapDecision, SourceMapKind } from '../core';\nimport type { OutputMatch, RollupSourceMapSetting, SourceMapHandling } from '../rollup/source-map-handling';\nimport { getOutputMatch, sourceMapKindFromRollupSetting } from '../rollup/source-map-handling';\n\ntype BundlerOutput = OutputMatch & { dir?: string; sourcemap?: RollupSourceMapSetting };\ntype BundlerOutputOptions = BundlerOutput | BundlerOutput[] | undefined;\n\ntype ViteBuildOptions = {\n sourcemap?: RollupSourceMapSetting;\n outDir?: string;\n rollupOptions?: { output?: BundlerOutputOptions };\n rolldownOptions?: { output?: BundlerOutputOptions };\n};\n\nexport type ViteUserConfig = {\n build?: ViteBuildOptions;\n environments?: Record<string, { build?: ViteBuildOptions } | undefined>;\n};\n\nexport type ViteResolvedConfig = {\n root: string;\n build: ViteBuildOptions;\n environments?: Record<string, { build: ViteBuildOptions }>;\n};\n\nexport type ViteSourceMapHooks = {\n config: (userConfig: ViteUserConfig, env: { command: string }) => ViteUserConfig | null;\n configResolved: (config: ViteResolvedConfig) => void;\n};\n\nconst NO_CHANGE: SourceMapDecision = { enableHidden: false, deleteAfterUpload: false };\n\ntype EnvironmentOutput = {\n destination: string;\n match: OutputMatch;\n sourcemap: RollupSourceMapSetting;\n /** The output sets `sourcemap` itself, which overrides `build.sourcemap`. */\n ownSetting: boolean;\n};\n\n/**\n * The outputs an environment writes: one per entry of `rollupOptions.output` or\n * `rolldownOptions.output`. An output writes to `build.outDir` (relative to the root) unless it\n * sets its own `dir`, which the bundler resolves from the working directory. An output's own\n * `sourcemap` overrides `build.sourcemap`.\n */\nfunction getOutputs(root: string, build: ViteBuildOptions): EnvironmentOutput[] {\n const configured = build.rolldownOptions?.output ?? build.rollupOptions?.output;\n const outputs = Array.isArray(configured) ? configured : [configured ?? {}];\n\n return outputs.map(output => {\n const sourcemap = output.sourcemap ?? build.sourcemap;\n return {\n destination: output.dir === undefined ? path.resolve(root, build.outDir ?? 'dist') : path.resolve(output.dir),\n match: getOutputMatch({ ...output, sourcemap }),\n sourcemap,\n ownSetting: output.sourcemap !== undefined,\n };\n });\n}\n\n/**\n * Vite warns about `rollupOptions.output.sourcemap`, so the Vite plugin decides on `build.sourcemap`\n * in a `config` hook. The hook belongs on the post plugin: framework plugins that set\n * `build.sourcemap` themselves run first, and the decision sees the merged setting. The output\n * directories are only known in `configResolved`, which then records the decision for each of them.\n */\nexport function createViteSourceMapHooks(\n sentryBuildPluginManager: SentryBuildPluginManager,\n sourceMapHandling: SourceMapHandling,\n): ViteSourceMapHooks {\n // `'*'` for the top-level setting, otherwise the name of an environment with its own.\n const decisions = new Map<string, { kind: SourceMapKind; decision: SourceMapDecision }>();\n\n return {\n config: (userConfig, env) => {\n if (env.command !== 'build') {\n return null;\n }\n\n // The same plugin instances can serve several builds in a row.\n decisions.clear();\n\n const kind = sourceMapKindFromRollupSetting(userConfig.build?.sourcemap);\n // Logged in `generateBundle`, which knows whether the output is written.\n const decision = sentryBuildPluginManager.sourceMaps.decide(kind, { log: false });\n decisions.set('*', { kind, decision });\n\n const result: ViteUserConfig = decision.enableHidden ? { build: { sourcemap: 'hidden' } } : {};\n\n for (const [name, environment] of Object.entries(userConfig.environments ?? {})) {\n const setting = environment?.build?.sourcemap;\n if (setting === undefined) {\n continue;\n }\n\n const environmentKind = sourceMapKindFromRollupSetting(setting);\n const environmentDecision = sentryBuildPluginManager.sourceMaps.decide(environmentKind, {
|
|
1
|
+
{"version":3,"file":"source-map-hooks.js","names":[],"sources":["../../../src/vite/source-map-hooks.ts"],"sourcesContent":["import * as path from 'node:path';\nimport type { SentryBuildPluginManager, SourceMapDecision, SourceMapKind } from '../core';\nimport { getDeleteSourcemapsAfterUpload, getSdkEnabledSourceMaps } from '../core';\nimport type { OutputMatch, RollupSourceMapSetting, SourceMapHandling } from '../rollup/source-map-handling';\nimport { getOutputMatch, sourceMapKindFromRollupSetting } from '../rollup/source-map-handling';\n\ntype BundlerOutput = OutputMatch & { dir?: string; sourcemap?: RollupSourceMapSetting };\ntype BundlerOutputOptions = BundlerOutput | BundlerOutput[] | undefined;\n\ntype ViteBuildOptions = {\n sourcemap?: RollupSourceMapSetting;\n outDir?: string;\n rollupOptions?: { output?: BundlerOutputOptions };\n rolldownOptions?: { output?: BundlerOutputOptions };\n};\n\nexport type ViteUserConfig = {\n build?: ViteBuildOptions;\n environments?: Record<string, { build?: ViteBuildOptions } | undefined>;\n};\n\nexport type ViteResolvedConfig = {\n root: string;\n build: ViteBuildOptions;\n environments?: Record<string, { build: ViteBuildOptions }>;\n};\n\nexport type ViteSourceMapHooks = {\n config: (userConfig: ViteUserConfig, env: { command: string }) => ViteUserConfig | null;\n configResolved: (config: ViteResolvedConfig) => void;\n};\n\nconst NO_CHANGE: SourceMapDecision = { enableHidden: false, deleteAfterUpload: false };\n\ntype EnvironmentOutput = {\n destination: string;\n match: OutputMatch;\n sourcemap: RollupSourceMapSetting;\n /** The output sets `sourcemap` itself, which overrides `build.sourcemap`. */\n ownSetting: boolean;\n};\n\n/**\n * The outputs an environment writes: one per entry of `rollupOptions.output` or\n * `rolldownOptions.output`. An output writes to `build.outDir` (relative to the root) unless it\n * sets its own `dir`, which the bundler resolves from the working directory. An output's own\n * `sourcemap` overrides `build.sourcemap`.\n */\nfunction getOutputs(root: string, build: ViteBuildOptions): EnvironmentOutput[] {\n const configured = build.rolldownOptions?.output ?? build.rollupOptions?.output;\n const outputs = Array.isArray(configured) ? configured : [configured ?? {}];\n\n return outputs.map(output => {\n const sourcemap = output.sourcemap ?? build.sourcemap;\n return {\n destination: output.dir === undefined ? path.resolve(root, build.outDir ?? 'dist') : path.resolve(output.dir),\n match: getOutputMatch({ ...output, sourcemap }),\n sourcemap,\n ownSetting: output.sourcemap !== undefined,\n };\n });\n}\n\n/**\n * Vite warns about `rollupOptions.output.sourcemap`, so the Vite plugin decides on `build.sourcemap`\n * in a `config` hook. The hook belongs on the post plugin: framework plugins that set\n * `build.sourcemap` themselves run first, and the decision sees the merged setting. The output\n * directories are only known in `configResolved`, which then records the decision for each of them.\n */\nexport function createViteSourceMapHooks(\n sentryBuildPluginManager: SentryBuildPluginManager,\n sourceMapHandling: SourceMapHandling,\n): ViteSourceMapHooks {\n // `'*'` for the top-level setting, otherwise the name of an environment with its own.\n const decisions = new Map<string, { kind: SourceMapKind; decision: SourceMapDecision }>();\n\n return {\n config: (userConfig, env) => {\n if (env.command !== 'build') {\n return null;\n }\n\n // The same plugin instances can serve several builds in a row.\n decisions.clear();\n\n const kind = sourceMapKindFromRollupSetting(userConfig.build?.sourcemap);\n // Logged in `generateBundle`, which knows whether the output is written.\n const decision = sentryBuildPluginManager.sourceMaps.decide(kind, { log: false });\n decisions.set('*', { kind, decision });\n\n const result: ViteUserConfig = decision.enableHidden ? { build: { sourcemap: 'hidden' } } : {};\n\n for (const [name, environment] of Object.entries(userConfig.environments ?? {})) {\n const setting = environment?.build?.sourcemap;\n if (setting === undefined) {\n continue;\n }\n\n const environmentKind = sourceMapKindFromRollupSetting(setting);\n const environmentDecision = sentryBuildPluginManager.sourceMaps.decide(environmentKind, {\n log: false,\n environment: name,\n });\n decisions.set(name, { kind: environmentKind, decision: environmentDecision });\n\n if (environmentDecision.enableHidden) {\n result.environments = { ...result.environments, [name]: { build: { sourcemap: 'hidden' } } };\n }\n }\n\n return result;\n },\n\n configResolved: config => {\n const environments = config.environments ?? { client: { build: config.build } };\n\n for (const [name, environment] of Object.entries(environments)) {\n const { kind, decision } = decisions.get(name) ?? decisions.get('*') ?? { kind: 'unset', decision: NO_CHANGE };\n const environmentName = decisions.has(name) ? name : undefined;\n const { normalizedOptions } = sentryBuildPluginManager;\n const deleteOption = getDeleteSourcemapsAfterUpload(normalizedOptions, environmentName);\n const sdkEnabledSourceMaps = getSdkEnabledSourceMaps(normalizedOptions, environmentName);\n\n for (const output of getOutputs(config.root, environment.build)) {\n // The plugin never changes an output's own setting. Hidden maps are\n // removed when the user asks for it, visible ones only when the SDK\n // turned source maps on.\n if (output.ownSetting) {\n const outputKind = sourceMapKindFromRollupSetting(output.sourcemap);\n const removeAllSourceMaps = sdkEnabledSourceMaps && (outputKind === 'hidden' || outputKind === 'visible');\n sourceMapHandling.setDecision(output.destination, {\n match: output.match,\n kind: outputKind,\n decision: {\n enableHidden: false,\n deleteAfterUpload: deleteOption === true && (outputKind === 'hidden' || removeAllSourceMaps),\n removeAllSourceMaps,\n },\n });\n continue;\n }\n\n // A plugin that ran after ours may have changed the setting again.\n if (decision.deleteAfterUpload && output.sourcemap !== 'hidden') {\n sentryBuildPluginManager.logger.debug(\n `Source maps of the \"${name}\" environment are set to ${JSON.stringify(output.sourcemap)}. Not removing them after upload.`,\n );\n sourceMapHandling.setDecision(output.destination, { match: output.match, kind, decision: NO_CHANGE });\n } else {\n sourceMapHandling.setDecision(output.destination, { match: output.match, kind, decision });\n }\n }\n }\n },\n };\n}\n"],"mappings":"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"}
|
|
@@ -1,27 +1,20 @@
|
|
|
1
|
+
import "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
// src/webpack/component-annotation-transform.ts
|
|
1
3
|
async function transform(source, map) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
callback(null, result.code, result.map || map);
|
|
16
|
-
}
|
|
17
|
-
} catch (error) {
|
|
18
|
-
if (error instanceof Error) {
|
|
19
|
-
callback(error);
|
|
20
|
-
} else {
|
|
21
|
-
callback(new Error(String(error)));
|
|
22
|
-
}
|
|
23
|
-
}
|
|
4
|
+
const callback = this.async();
|
|
5
|
+
const { transform: transformFn } = this.query;
|
|
6
|
+
if (!transformFn) return callback(null, source, map);
|
|
7
|
+
try {
|
|
8
|
+
const id = this.resourcePath;
|
|
9
|
+
const result = await transformFn(source, id);
|
|
10
|
+
if (result == null) callback(null, source, map);
|
|
11
|
+
else if (typeof result === "string") callback(null, result, map);
|
|
12
|
+
else callback(null, result.code, result.map || map);
|
|
13
|
+
} catch (error) {
|
|
14
|
+
if (error instanceof Error) callback(error);
|
|
15
|
+
else callback(new Error(String(error)));
|
|
16
|
+
}
|
|
24
17
|
}
|
|
25
|
-
|
|
26
18
|
export { transform as default };
|
|
27
|
-
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=component-annotation-transform.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-annotation-transform.js","sources":["../../../src/webpack/component-annotation-transform.ts"],"sourcesContent":["// Webpack loader for component annotation transform\n// Based on unplugin v1.0.1 transform loader pattern\n\nexport default async function transform(\n this: {\n async: () => (err: Error | null, content?: string, sourceMap?: unknown) => void;\n resourcePath: string;\n query: {\n transform?: (code: string, id: string) => Promise<{ code: string; map?: unknown } | null | undefined | string>;\n };\n },\n source: string,\n map: unknown,\n): Promise<void> {\n const callback = this.async();\n const { transform: transformFn } = this.query;\n\n if (!transformFn) {\n return callback(null, source, map);\n }\n\n try {\n const id = this.resourcePath;\n const result = await transformFn(source, id);\n\n if (result == null) {\n callback(null, source, map);\n } else if (typeof result === 'string') {\n callback(null, result, map);\n } else {\n callback(null, result.code, result.map || map);\n }\n } catch (error) {\n if (error instanceof Error) {\n callback(error);\n } else {\n callback(new Error(String(error)));\n }\n }\n}\n"],"
|
|
1
|
+
{"version":3,"file":"component-annotation-transform.js","names":[],"sources":["../../../src/webpack/component-annotation-transform.ts"],"sourcesContent":["// Webpack loader for component annotation transform\n// Based on unplugin v1.0.1 transform loader pattern\n\nexport default async function transform(\n this: {\n async: () => (err: Error | null, content?: string, sourceMap?: unknown) => void;\n resourcePath: string;\n query: {\n transform?: (code: string, id: string) => Promise<{ code: string; map?: unknown } | null | undefined | string>;\n };\n },\n source: string,\n map: unknown,\n): Promise<void> {\n const callback = this.async();\n const { transform: transformFn } = this.query;\n\n if (!transformFn) {\n return callback(null, source, map);\n }\n\n try {\n const id = this.resourcePath;\n const result = await transformFn(source, id);\n\n if (result == null) {\n callback(null, source, map);\n } else if (typeof result === 'string') {\n callback(null, result, map);\n } else {\n callback(null, result.code, result.map || map);\n }\n } catch (error) {\n if (error instanceof Error) {\n callback(error);\n } else {\n callback(new Error(String(error)));\n }\n }\n}\n"],"mappings":";;AAGA,eAA8B,UAQ5B,QACA,KACe;CACf,MAAM,WAAW,KAAK,MAAM;CAC5B,MAAM,EAAE,WAAW,gBAAgB,KAAK;CAExC,IAAI,CAAC,aACH,OAAO,SAAS,MAAM,QAAQ,GAAG;CAGnC,IAAI;EACF,MAAM,KAAK,KAAK;EAChB,MAAM,SAAS,MAAM,YAAY,QAAQ,EAAE;EAE3C,IAAI,UAAU,MACZ,SAAS,MAAM,QAAQ,GAAG;OACrB,IAAI,OAAO,WAAW,UAC3B,SAAS,MAAM,QAAQ,GAAG;OAE1B,SAAS,MAAM,OAAO,MAAM,OAAO,OAAO,GAAG;CAEjD,SAAS,OAAO;EACd,IAAI,iBAAiB,OACnB,SAAS,KAAK;OAEd,SAAS,IAAI,MAAM,OAAO,KAAK,CAAC,CAAC;CAErC;AACF"}
|