@sentry/bundler-plugins 11.11.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 -683
- 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 +52 -0
- package/build/cjs/core/upload-filter.js.map +1 -0
- 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 -210
- 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 +195 -209
- package/build/cjs/rollup/index.js.map +1 -1
- package/build/cjs/rollup/source-map-handling.js +178 -0
- package/build/cjs/rollup/source-map-handling.js.map +1 -0
- package/build/cjs/vite/index.js +19 -35
- package/build/cjs/vite/index.js.map +1 -1
- package/build/cjs/vite/source-map-hooks.js +116 -0
- package/build/cjs/vite/source-map-hooks.js.map +1 -0
- 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 +277 -234
- 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 -664
- 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 +50 -0
- package/build/esm/core/upload-filter.js.map +1 -0
- 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 -194
- 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 +191 -189
- package/build/esm/rollup/index.js.map +1 -1
- package/build/esm/rollup/source-map-handling.js +173 -0
- package/build/esm/rollup/source-map-handling.js.map +1 -0
- package/build/esm/vite/index.js +19 -32
- package/build/esm/vite/index.js.map +1 -1
- package/build/esm/vite/source-map-hooks.js +114 -0
- package/build/esm/vite/source-map-hooks.js.map +1 -0
- 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 +274 -216
- package/build/esm/webpack/index.js.map +1 -1
- package/build/types/core/build-plugin-manager.d.ts +33 -10
- 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 +4 -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 +32 -1
- package/build/types/core/types.d.ts.map +1 -1
- package/build/types/core/upload-filter.d.ts +9 -0
- package/build/types/core/upload-filter.d.ts.map +1 -0
- package/build/types/core/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 +107 -7
- package/build/types/rollup/index.d.ts.map +1 -1
- package/build/types/rollup/source-map-handling.d.ts +59 -0
- package/build/types/rollup/source-map-handling.d.ts.map +1 -0
- package/build/types/vite/index.d.ts +4 -8
- package/build/types/vite/index.d.ts.map +1 -1
- package/build/types/vite/source-map-hooks.d.ts +45 -0
- package/build/types/vite/source-map-hooks.d.ts.map +1 -0
- package/build/types/webpack/index.d.ts +7 -3
- package/build/types/webpack/index.d.ts.map +1 -1
- package/package.json +33 -38
- package/build/cjs/loader-utils/index.js.map +0 -1
- package/build/esm/loader-utils/index.js.map +0 -1
|
@@ -1,247 +1,290 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (e && e.__esModule) return e;
|
|
17
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
|
|
18
|
-
if (e) {
|
|
19
|
-
for (const k in e) {
|
|
20
|
-
n[k] = e[k];
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
n.default = e;
|
|
24
|
-
return n;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
28
|
-
|
|
29
|
-
const _req = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('webpack/index.js', document.baseURI).href)));
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.js");
|
|
3
|
+
const require_utils = require("../core/utils.js");
|
|
4
|
+
const require_get_code_injection_position = require("../core/get-code-injection-position.js");
|
|
5
|
+
const require_component_annotate_hooks = require("../core/component-annotate-hooks.js");
|
|
6
|
+
const require_debug_id_upload = require("../core/debug-id-upload.js");
|
|
7
|
+
const require_build_plugin_manager = require("../core/build-plugin-manager.js");
|
|
8
|
+
const require_index = require("../core/index.js");
|
|
9
|
+
let node_path = require("node:path");
|
|
10
|
+
node_path = require_runtime.__toESM(node_path);
|
|
11
|
+
let node_module = require("node:module");
|
|
12
|
+
let node_crypto = require("node:crypto");
|
|
13
|
+
let node_url = require("node:url");
|
|
14
|
+
// src/webpack/index.ts
|
|
15
|
+
const _req = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
30
16
|
let COMPONENT_ANNOTATION_LOADER;
|
|
31
17
|
try {
|
|
32
|
-
|
|
18
|
+
COMPONENT_ANNOTATION_LOADER = _req.resolve("@sentry/bundler-plugins/webpack-loader");
|
|
33
19
|
} catch {
|
|
34
|
-
|
|
35
|
-
|
|
20
|
+
const dirname = node_path.dirname((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
21
|
+
COMPONENT_ANNOTATION_LOADER = node_path.resolve(dirname, "component-annotation-transform.js");
|
|
36
22
|
}
|
|
37
23
|
const WEBPACK_JAVASCRIPT_ASSET_REGEX = /\.(?:js|ts|jsx|tsx|mjs|cjs|mts|cts)(?:\?[^?]*)?(?:#[^#]*)?$/;
|
|
24
|
+
/**
|
|
25
|
+
* Maps webpack's `devtool` onto the plugin's source map kinds. A user who sets `devtool: false`
|
|
26
|
+
* and adds a `SourceMapDevToolPlugin` manages source maps themselves.
|
|
27
|
+
*/
|
|
28
|
+
function sourceMapKindFromDevtool(compiler) {
|
|
29
|
+
const devtool = compiler.options.devtool;
|
|
30
|
+
if (devtool === void 0) return "unset";
|
|
31
|
+
if (devtool === false) return compiler.options.plugins?.some((plugin) => plugin?.constructor?.name === "SourceMapDevToolPlugin") ? void 0 : "off";
|
|
32
|
+
if (!devtool.includes("source-map")) return "off";
|
|
33
|
+
if (devtool.includes("inline") || devtool.includes("eval")) return "inline";
|
|
34
|
+
if (devtool.includes("hidden")) return "hidden";
|
|
35
|
+
return "visible";
|
|
36
|
+
}
|
|
38
37
|
function getWebpackMajorVersion() {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
38
|
+
try {
|
|
39
|
+
const webpack = _req("webpack");
|
|
40
|
+
return (webpack.version ?? webpack.default?.version)?.split(".")[0];
|
|
41
|
+
} catch {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
46
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Stamps each JS asset's debug ID into the asset itself and its source map asset.
|
|
47
|
+
*
|
|
48
|
+
* Runs after source maps have been generated, so the JS asset no longer needs to carry
|
|
49
|
+
* source map information and can be replaced with a plain `RawSource`.
|
|
50
|
+
*/
|
|
47
51
|
function addDebugIdsToAssets(compilation, RawSource) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
52
|
+
for (const asset of compilation.getAssets()) {
|
|
53
|
+
if (!require_index.isJsFile(asset.name)) continue;
|
|
54
|
+
const bundleSource = asset.source.source().toString();
|
|
55
|
+
const relatedSourceMap = asset.info.related?.sourceMap;
|
|
56
|
+
const sourceMapName = typeof relatedSourceMap === "string" ? relatedSourceMap : `${asset.name}.map`;
|
|
57
|
+
const sourceMapAsset = compilation.getAsset(sourceMapName);
|
|
58
|
+
const stamped = require_debug_id_upload.stampDebugId(bundleSource, sourceMapAsset?.source.source().toString());
|
|
59
|
+
if (!stamped) continue;
|
|
60
|
+
compilation.updateAsset(asset.name, new RawSource(stamped.bundleSource));
|
|
61
|
+
if (stamped.sourceMapSource !== void 0) compilation.updateAsset(sourceMapName, new RawSource(stamped.sourceMapSource));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/** Drops a source map asset and its compressed variants from the compilation. */
|
|
65
|
+
function deleteSourceMapAssets(compilation, sourceMapName) {
|
|
66
|
+
for (const candidate of compilation.getAssets()) if (candidate.name === sourceMapName || candidate.name.startsWith(`${sourceMapName}.`)) compilation.deleteAsset(candidate.name);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Drops the source maps of the JS assets that an upload would include. With `removeAll` it drops
|
|
70
|
+
* the source maps of all assets, CSS included.
|
|
71
|
+
*/
|
|
72
|
+
function dropSourceMaps(compilation, shouldUpload, removeAll) {
|
|
73
|
+
const outputPath = compilation.outputOptions.path ?? node_path.resolve();
|
|
74
|
+
for (const asset of compilation.getAssets()) {
|
|
75
|
+
if (!removeAll && (!require_index.isJsFile(asset.name) || !shouldUpload(node_path.join(outputPath, asset.name)))) continue;
|
|
76
|
+
const relatedSourceMap = asset.info.related?.sourceMap;
|
|
77
|
+
const sourceMapName = typeof relatedSourceMap === "string" ? relatedSourceMap : `${asset.name}.map`;
|
|
78
|
+
if (compilation.getAsset(sourceMapName)) deleteSourceMapAssets(compilation, sourceMapName);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Copies each JS asset and its source map into the upload staging folder and drops the source map
|
|
83
|
+
* assets (and their compressed variants) from the compilation, so webpack never emits them.
|
|
84
|
+
*
|
|
85
|
+
* A map the plugin or the SDK turned on (`pluginEnabledMaps`) never reaches the output, whether or
|
|
86
|
+
* not its asset is uploaded. That covers CSS maps, which `devtool` turns on along with the JS ones.
|
|
87
|
+
* A map the user enabled stays unless it was staged.
|
|
88
|
+
*/
|
|
89
|
+
async function stageSourceMaps(compilation, staging, logger, pluginEnabledMaps) {
|
|
90
|
+
const outputPath = compilation.outputOptions.path ?? node_path.resolve();
|
|
91
|
+
for (const asset of compilation.getAssets()) {
|
|
92
|
+
const relatedSourceMap = asset.info.related?.sourceMap;
|
|
93
|
+
const sourceMapName = typeof relatedSourceMap === "string" ? relatedSourceMap : `${asset.name}.map`;
|
|
94
|
+
const sourceMapAsset = compilation.getAsset(sourceMapName);
|
|
95
|
+
if (!sourceMapAsset) continue;
|
|
96
|
+
if (!require_index.isJsFile(asset.name)) {
|
|
97
|
+
if (pluginEnabledMaps) deleteSourceMapAssets(compilation, sourceMapName);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const result = await staging.stage({
|
|
101
|
+
code: asset.source.source().toString(),
|
|
102
|
+
mapSource: sourceMapAsset.source.source().toString(),
|
|
103
|
+
mapDir: node_path.join(outputPath, node_path.dirname(sourceMapName)),
|
|
104
|
+
chunkPath: node_path.join(outputPath, asset.name)
|
|
105
|
+
});
|
|
106
|
+
if (result === "skipped" || result === "failed") logger.warn(pluginEnabledMaps ? `Could not prepare ${asset.name} for upload, so it is not uploaded and its source map ${sourceMapName} was removed from the build output.` : `Could not prepare ${asset.name} for upload, so its source map ${sourceMapName} stays in the build output.`);
|
|
107
|
+
if (result === "staged" || pluginEnabledMaps) deleteSourceMapAssets(compilation, sourceMapName);
|
|
108
|
+
}
|
|
65
109
|
}
|
|
66
110
|
function createSentryWebpackPlugin(userOptions = {}) {
|
|
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
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
};
|
|
111
|
+
const sentryBuildPluginManager = require_build_plugin_manager.createSentryBuildPluginManager(userOptions, {
|
|
112
|
+
loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? "[sentry-webpack-plugin]",
|
|
113
|
+
buildTool: "webpack",
|
|
114
|
+
buildToolMajorVersion: getWebpackMajorVersion()
|
|
115
|
+
});
|
|
116
|
+
const { logger, normalizedOptions: options, bundleSizeOptimizationReplacementValues: replacementValues, bundleMetadata, createDependencyOnBuildArtifacts } = sentryBuildPluginManager;
|
|
117
|
+
if (options.disable) return { apply() {} };
|
|
118
|
+
if (process.cwd().match(/\\node_modules\\|\/node_modules\//)) logger.warn("Running Sentry plugin from within a `node_modules` folder. Some features may not work.");
|
|
119
|
+
const sourcemapsEnabled = options.sourcemaps?.disable !== true;
|
|
120
|
+
const releaseInjectionCode = new require_utils.CodeInjection();
|
|
121
|
+
const chunkInjectionCode = new require_utils.CodeInjection();
|
|
122
|
+
if (!options.release.inject) logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
|
|
123
|
+
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.");
|
|
124
|
+
else releaseInjectionCode.append(require_utils.generateReleaseInjectorCode({
|
|
125
|
+
release: options.release.name,
|
|
126
|
+
injectBuildInformation: options._experiments.injectBuildInformation || false
|
|
127
|
+
}));
|
|
128
|
+
if (Object.keys(bundleMetadata).length > 0) chunkInjectionCode.append(require_utils.generateModuleMetadataInjectorCode(bundleMetadata));
|
|
129
|
+
const transformAnnotations = options.reactComponentAnnotation?.enabled ? require_component_annotate_hooks.createComponentNameAnnotateHooks(options.reactComponentAnnotation?.ignoredComponents || [], !!options.reactComponentAnnotation?._experimentalInjectIntoHtml, { logger }) : void 0;
|
|
130
|
+
const transformReplace = Object.keys(replacementValues).length > 0;
|
|
131
|
+
function decideSourceMaps(compiler) {
|
|
132
|
+
const kind = compiler.options.mode === "development" ? void 0 : sourceMapKindFromDevtool(compiler);
|
|
133
|
+
if (kind === void 0) return { decision: {
|
|
134
|
+
enableHidden: false,
|
|
135
|
+
deleteAfterUpload: false
|
|
136
|
+
} };
|
|
137
|
+
const decision = sentryBuildPluginManager.sourceMaps.decide(kind);
|
|
138
|
+
if (decision.enableHidden) compiler.options.devtool = kind === "visible" ? `hidden-${compiler.options.devtool}` : "hidden-source-map";
|
|
139
|
+
return {
|
|
140
|
+
kind,
|
|
141
|
+
decision
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function addCodeInjection(compiler) {
|
|
145
|
+
if (releaseInjectionCode.isEmpty() && chunkInjectionCode.isEmpty() && !sourcemapsEnabled) return;
|
|
146
|
+
const ReplaceSource = compiler.webpack?.sources?.ReplaceSource;
|
|
147
|
+
const processAssetsStage = compiler.webpack?.Compilation?.PROCESS_ASSETS_STAGE_ADDITIONS;
|
|
148
|
+
if (!ReplaceSource || processAssetsStage === void 0) {
|
|
149
|
+
logger.warn("Webpack sources are not available. Skipping code injection. This usually means webpack is not properly configured.");
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
compiler.hooks.compilation.tap("sentry-webpack-plugin-injection", (compilation) => {
|
|
153
|
+
compilation.hooks.processAssets.tap({
|
|
154
|
+
name: "sentry-webpack-plugin-injection",
|
|
155
|
+
stage: processAssetsStage
|
|
156
|
+
}, (assets) => {
|
|
157
|
+
const injectedAssets = /* @__PURE__ */ new Set();
|
|
158
|
+
for (const chunk of compilation.chunks) for (const assetName of chunk.files) {
|
|
159
|
+
if (injectedAssets.has(assetName) || !WEBPACK_JAVASCRIPT_ASSET_REGEX.test(assetName)) continue;
|
|
160
|
+
const source = assets[assetName];
|
|
161
|
+
if (!source) continue;
|
|
162
|
+
injectedAssets.add(assetName);
|
|
163
|
+
const sourceContents = source.source();
|
|
164
|
+
const code = typeof sourceContents === "string" ? sourceContents : Buffer.from(sourceContents).toString();
|
|
165
|
+
const codeToInject = new require_utils.CodeInjection();
|
|
166
|
+
if (chunk.canBeInitial?.() ?? true) codeToInject.append(releaseInjectionCode);
|
|
167
|
+
codeToInject.append(chunkInjectionCode);
|
|
168
|
+
if (sourcemapsEnabled) {
|
|
169
|
+
const hash = chunk.contentHash?.javascript ?? chunk.hash;
|
|
170
|
+
codeToInject.append(require_index.getDebugIdSnippet(hash ? require_utils.stringToUUID(hash) : (0, node_crypto.randomUUID)()));
|
|
171
|
+
}
|
|
172
|
+
const injectionPosition = require_get_code_injection_position.getCodeInjectionPosition(code);
|
|
173
|
+
const injection = injectionPosition === code.length ? `\n${codeToInject.code()}` : codeToInject.code();
|
|
174
|
+
const updatedSource = new ReplaceSource(source);
|
|
175
|
+
updatedSource.insert(injectionPosition, injection);
|
|
176
|
+
compilation.updateAsset(assetName, updatedSource);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
return { apply(compiler) {
|
|
182
|
+
sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {});
|
|
183
|
+
const { DefinePlugin } = compiler.webpack ?? {};
|
|
184
|
+
const { decision: sourceMapDecision } = decideSourceMaps(compiler);
|
|
185
|
+
const removeAllSourceMaps = sourceMapDecision.removeAllSourceMaps === true;
|
|
186
|
+
const pendingStagings = /* @__PURE__ */ new Map();
|
|
187
|
+
const deleteStage = (compiler.webpack?.Compilation?.PROCESS_ASSETS_STAGE_REPORT ?? 5e3) + 1;
|
|
188
|
+
if (sourceMapDecision.deleteAfterUpload && !sentryBuildPluginManager.sourceMaps.uploadPossible) compiler.hooks.thisCompilation.tap("sentry-webpack-plugin", (compilation) => {
|
|
189
|
+
compilation.hooks.processAssets.tap({
|
|
190
|
+
name: "sentry-webpack-plugin",
|
|
191
|
+
stage: deleteStage
|
|
192
|
+
}, () => {
|
|
193
|
+
dropSourceMaps(compilation, sentryBuildPluginManager.sourceMaps.shouldUpload, removeAllSourceMaps);
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
else if (sourceMapDecision.deleteAfterUpload) {
|
|
197
|
+
compiler.hooks.thisCompilation.tap("sentry-webpack-plugin", (compilation) => {
|
|
198
|
+
compilation.hooks.processAssets.tapPromise({
|
|
199
|
+
name: "sentry-webpack-plugin",
|
|
200
|
+
stage: deleteStage
|
|
201
|
+
}, async () => {
|
|
202
|
+
const staging = await sentryBuildPluginManager.createUploadStaging();
|
|
203
|
+
pendingStagings.set(compilation, staging);
|
|
204
|
+
await stageSourceMaps(compilation, staging, logger, removeAllSourceMaps);
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
const emittedCompilations = /* @__PURE__ */ new Set();
|
|
208
|
+
compiler.hooks.emit.tap("sentry-webpack-plugin", (compilation) => {
|
|
209
|
+
emittedCompilations.add(compilation);
|
|
210
|
+
});
|
|
211
|
+
const settlePendingStagings = () => {
|
|
212
|
+
for (const [compilation, staging] of pendingStagings) if (emittedCompilations.has(compilation)) staging.keep("The source map upload did not run.");
|
|
213
|
+
else staging.discard();
|
|
214
|
+
pendingStagings.clear();
|
|
215
|
+
emittedCompilations.clear();
|
|
216
|
+
};
|
|
217
|
+
compiler.hooks.done.tap("sentry-webpack-plugin", settlePendingStagings);
|
|
218
|
+
compiler.hooks.failed?.tap("sentry-webpack-plugin", settlePendingStagings);
|
|
219
|
+
}
|
|
220
|
+
addCodeInjection(compiler);
|
|
221
|
+
if (sourcemapsEnabled && options.sourcemaps?.disable === "disable-upload") {
|
|
222
|
+
const RawSource = compiler.webpack?.sources?.RawSource;
|
|
223
|
+
const stage = (compiler.webpack?.Compilation?.PROCESS_ASSETS_STAGE_DEV_TOOLING ?? 500) + 1;
|
|
224
|
+
if (!RawSource) logger.warn("Webpack sources are not available. Skipping debug ID injection into emitted source maps. This usually means webpack is not properly configured.");
|
|
225
|
+
else compiler.hooks.thisCompilation.tap("sentry-webpack-plugin", (compilation) => {
|
|
226
|
+
compilation.hooks.processAssets.tap({
|
|
227
|
+
name: "sentry-webpack-plugin",
|
|
228
|
+
stage
|
|
229
|
+
}, () => {
|
|
230
|
+
addDebugIdsToAssets(compilation, RawSource);
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
if (transformReplace && DefinePlugin) {
|
|
235
|
+
compiler.options.plugins = compiler.options.plugins || [];
|
|
236
|
+
compiler.options.plugins.push(new DefinePlugin(replacementValues));
|
|
237
|
+
}
|
|
238
|
+
if (transformAnnotations?.transform) {
|
|
239
|
+
compiler.options.module = compiler.options.module || {};
|
|
240
|
+
compiler.options.module.rules = compiler.options.module.rules || [];
|
|
241
|
+
compiler.options.module.rules.unshift({
|
|
242
|
+
test: /\.[jt]sx$/,
|
|
243
|
+
exclude: /node_modules/,
|
|
244
|
+
enforce: "pre",
|
|
245
|
+
use: [{
|
|
246
|
+
loader: COMPONENT_ANNOTATION_LOADER,
|
|
247
|
+
options: { transform: transformAnnotations.transform }
|
|
248
|
+
}]
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
compiler.hooks.afterEmit.tapAsync("sentry-webpack-plugin", (compilation, callback) => {
|
|
252
|
+
const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
|
|
253
|
+
const upload = require_debug_id_upload.createDebugIdUploadFunction({ sentryBuildPluginManager });
|
|
254
|
+
const staging = pendingStagings.get(compilation);
|
|
255
|
+
pendingStagings.delete(compilation);
|
|
256
|
+
let stagingHandedOver = false;
|
|
257
|
+
const run = async () => {
|
|
258
|
+
try {
|
|
259
|
+
await sentryBuildPluginManager.createRelease();
|
|
260
|
+
if (sourcemapsEnabled && options.sourcemaps?.disable !== "disable-upload") {
|
|
261
|
+
const outputPath = compilation.outputOptions.path ?? node_path.resolve();
|
|
262
|
+
const buildArtifacts = Object.keys(compilation.assets).map((asset) => node_path.join(outputPath, asset));
|
|
263
|
+
stagingHandedOver = true;
|
|
264
|
+
await upload(buildArtifacts, { staging });
|
|
265
|
+
} else {
|
|
266
|
+
stagingHandedOver = true;
|
|
267
|
+
await staging?.discard();
|
|
268
|
+
}
|
|
269
|
+
} catch (e) {
|
|
270
|
+
if (!stagingHandedOver) await staging?.keep("The source map upload did not run.");
|
|
271
|
+
throw e;
|
|
272
|
+
} finally {
|
|
273
|
+
freeGlobalDependencyOnBuildArtifacts();
|
|
274
|
+
await sentryBuildPluginManager.deleteArtifacts();
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
run().then(() => callback(), (err) => callback(err));
|
|
278
|
+
});
|
|
279
|
+
if (userOptions._experiments?.forceExitOnBuildCompletion && compiler.options.mode === "production") compiler.hooks.done.tap("sentry-webpack-plugin", () => {
|
|
280
|
+
setTimeout(() => {
|
|
281
|
+
logger.debug("Exiting process after debug file upload");
|
|
282
|
+
process.exit(0);
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
} };
|
|
243
286
|
}
|
|
244
287
|
const sentryWebpackPlugin = createSentryWebpackPlugin;
|
|
245
|
-
|
|
246
288
|
exports.sentryWebpackPlugin = sentryWebpackPlugin;
|
|
247
|
-
|
|
289
|
+
|
|
290
|
+
//# sourceMappingURL=index.js.map
|