@sentry/webpack-plugin 4.9.1 → 5.1.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.
@@ -0,0 +1,22 @@
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
+
3
+ //#region src/component-annotation-transform.ts
4
+ async function transform(source, map) {
5
+ const callback = this.async();
6
+ const { transform: transformFn } = this.query;
7
+ if (!transformFn) return callback(null, source, map);
8
+ try {
9
+ const id = this.resourcePath;
10
+ const result = await transformFn(source, id);
11
+ if (result == null) callback(null, source, map);
12
+ else if (typeof result === "string") callback(null, result, map);
13
+ else callback(null, result.code, result.map || map);
14
+ } catch (error) {
15
+ if (error instanceof Error) callback(error);
16
+ else callback(new Error(String(error)));
17
+ }
18
+ }
19
+
20
+ //#endregion
21
+ exports.default = transform;
22
+ //# sourceMappingURL=component-annotation-transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-annotation-transform.js","names":[],"sources":["../../src/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?: (\n code: string,\n id: string\n ) => 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,UAW5B,QACA,KACe;CACf,MAAM,WAAW,KAAK,OAAO;CAC7B,MAAM,EAAE,WAAW,gBAAgB,KAAK;AAExC,KAAI,CAAC,YACH,QAAO,SAAS,MAAM,QAAQ,IAAI;AAGpC,KAAI;EACF,MAAM,KAAK,KAAK;EAChB,MAAM,SAAS,MAAM,YAAY,QAAQ,GAAG;AAE5C,MAAI,UAAU,KACZ,UAAS,MAAM,QAAQ,IAAI;WAClB,OAAO,WAAW,SAC3B,UAAS,MAAM,QAAQ,IAAI;MAE3B,UAAS,MAAM,OAAO,MAAM,OAAO,OAAO,IAAI;UAEzC,OAAO;AACd,MAAI,iBAAiB,MACnB,UAAS,MAAM;MAEf,UAAS,IAAI,MAAM,OAAO,MAAM,CAAC,CAAC"}
package/dist/cjs/index.js CHANGED
@@ -1,48 +1,158 @@
1
- 'use strict';
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ //#region \0rolldown/runtime.js
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
+ key = keys[i];
13
+ if (!__hasOwnProp.call(to, key) && key !== except) {
14
+ __defProp(to, key, {
15
+ get: ((k) => from[k]).bind(null, key),
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ }
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
2
27
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
28
+ //#endregion
29
+ let _sentry_bundler_plugin_core = require("@sentry/bundler-plugin-core");
30
+ let node_path = require("node:path");
31
+ node_path = __toESM(node_path);
32
+ let node_url = require("node:url");
33
+ let node_module = require("node:module");
34
+ let uuid = require("uuid");
35
+ let webpack = require("webpack");
36
+ webpack = __toESM(webpack);
4
37
 
5
- var webpack4and5 = require('./webpack4and5.js');
6
- var webpack4or5 = require('webpack');
7
- var bundlerPluginCore = require('@sentry/bundler-plugin-core');
8
- require('node:module');
9
- require('path');
10
- require('uuid');
11
-
12
- function _interopNamespace(e) {
13
- if (e && e.__esModule) return e;
14
- var n = Object.create(null);
15
- if (e) {
16
- Object.keys(e).forEach(function (k) {
17
- if (k !== 'default') {
18
- var d = Object.getOwnPropertyDescriptor(e, k);
19
- Object.defineProperty(n, k, d.get ? d : {
20
- enumerable: true,
21
- get: function () { return e[k]; }
22
- });
23
- }
24
- });
25
- }
26
- n["default"] = e;
27
- return Object.freeze(n);
38
+ //#region src/webpack4and5.ts
39
+ const dirname = node_path.dirname((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
40
+ const COMPONENT_ANNOTATION_LOADER = node_path.resolve(dirname, typeof __dirname !== "undefined" ? "component-annotation-transform.js" : "component-annotation-transform.mjs");
41
+ function getWebpackMajorVersion() {
42
+ try {
43
+ const webpack = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("webpack");
44
+ return (webpack?.version ?? webpack?.default?.version)?.split(".")[0];
45
+ } catch (error) {
46
+ return;
47
+ }
48
+ }
49
+ /**
50
+ * The factory function accepts BannerPlugin and DefinePlugin classes in
51
+ * order to avoid direct dependencies on webpack.
52
+ *
53
+ * This allow us to export version of the plugin for webpack 5.1+ and compatible environments.
54
+ *
55
+ * Since webpack 5.1 compiler contains webpack module so plugins always use correct webpack version.
56
+ */
57
+ function sentryWebpackPluginFactory({ BannerPlugin: UnsafeBannerPlugin, DefinePlugin: UnsafeDefinePlugin } = {}) {
58
+ return function sentryWebpackPlugin(userOptions = {}) {
59
+ const sentryBuildPluginManager = (0, _sentry_bundler_plugin_core.createSentryBuildPluginManager)(userOptions, {
60
+ loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? "[sentry-webpack-plugin]",
61
+ buildTool: "webpack",
62
+ buildToolMajorVersion: getWebpackMajorVersion()
63
+ });
64
+ const { logger, normalizedOptions: options, bundleSizeOptimizationReplacementValues: replacementValues, bundleMetadata, createDependencyOnBuildArtifacts } = sentryBuildPluginManager;
65
+ if (options.disable) return { apply() {} };
66
+ if (process.cwd().match(/\\node_modules\\|\/node_modules\//)) logger.warn("Running Sentry plugin from within a `node_modules` folder. Some features may not work.");
67
+ const sourcemapsEnabled = options.sourcemaps?.disable !== true;
68
+ const staticInjectionCode = new _sentry_bundler_plugin_core.CodeInjection();
69
+ if (!options.release.inject) logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
70
+ 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.");
71
+ else staticInjectionCode.append((0, _sentry_bundler_plugin_core.generateReleaseInjectorCode)({
72
+ release: options.release.name,
73
+ injectBuildInformation: options._experiments.injectBuildInformation || false
74
+ }));
75
+ if (Object.keys(bundleMetadata).length > 0) staticInjectionCode.append((0, _sentry_bundler_plugin_core.generateModuleMetadataInjectorCode)(bundleMetadata));
76
+ const transformAnnotations = options.reactComponentAnnotation?.enabled ? (0, _sentry_bundler_plugin_core.createComponentNameAnnotateHooks)(options.reactComponentAnnotation?.ignoredComponents || [], !!options.reactComponentAnnotation?._experimentalInjectIntoHtml) : void 0;
77
+ const transformReplace = Object.keys(replacementValues).length > 0;
78
+ return { apply(compiler) {
79
+ sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {});
80
+ const BannerPlugin = compiler?.webpack?.BannerPlugin || UnsafeBannerPlugin;
81
+ const DefinePlugin = compiler?.webpack?.DefinePlugin || UnsafeDefinePlugin;
82
+ if (!staticInjectionCode.isEmpty() || sourcemapsEnabled) if (!BannerPlugin) logger.warn("BannerPlugin is not available. Skipping code injection. This usually means webpack is not properly configured.");
83
+ else {
84
+ compiler.options.plugins = compiler.options.plugins || [];
85
+ compiler.options.plugins.push(new BannerPlugin({
86
+ raw: true,
87
+ include: /\.(js|ts|jsx|tsx|mjs|cjs)(\?[^?]*)?(#[^#]*)?$/,
88
+ banner: (arg) => {
89
+ const codeToInject = staticInjectionCode.clone();
90
+ if (sourcemapsEnabled) {
91
+ const hash = arg?.chunk?.contentHash?.javascript ?? arg?.chunk?.hash;
92
+ const debugId = hash ? (0, _sentry_bundler_plugin_core.stringToUUID)(hash) : (0, uuid.v4)();
93
+ codeToInject.append((0, _sentry_bundler_plugin_core.getDebugIdSnippet)(debugId));
94
+ }
95
+ return codeToInject.code();
96
+ }
97
+ }));
98
+ }
99
+ if (transformReplace && DefinePlugin) {
100
+ compiler.options.plugins = compiler.options.plugins || [];
101
+ compiler.options.plugins.push(new DefinePlugin(replacementValues));
102
+ }
103
+ if (transformAnnotations?.transform) {
104
+ compiler.options.module = compiler.options.module || {};
105
+ compiler.options.module.rules = compiler.options.module.rules || [];
106
+ compiler.options.module.rules.unshift({
107
+ test: /\.[jt]sx$/,
108
+ exclude: /node_modules/,
109
+ enforce: "pre",
110
+ use: [{
111
+ loader: COMPONENT_ANNOTATION_LOADER,
112
+ options: { transform: transformAnnotations.transform }
113
+ }]
114
+ });
115
+ }
116
+ compiler.hooks.afterEmit.tapAsync("sentry-webpack-plugin", (compilation, callback) => {
117
+ const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
118
+ const upload = (0, _sentry_bundler_plugin_core.createDebugIdUploadFunction)({ sentryBuildPluginManager });
119
+ sentryBuildPluginManager.createRelease().then(async () => {
120
+ if (sourcemapsEnabled && options.sourcemaps?.disable !== "disable-upload") {
121
+ const outputPath = compilation.outputOptions.path ?? node_path.resolve();
122
+ await upload(Object.keys(compilation.assets).map((asset) => node_path.join(outputPath, asset)));
123
+ }
124
+ }).then(() => {
125
+ callback();
126
+ }).finally(() => {
127
+ freeGlobalDependencyOnBuildArtifacts();
128
+ sentryBuildPluginManager.deleteArtifacts();
129
+ });
130
+ });
131
+ if (userOptions._experiments?.forceExitOnBuildCompletion && compiler.options.mode === "production") compiler.hooks.done.tap("sentry-webpack-plugin", () => {
132
+ setTimeout(() => {
133
+ logger.debug("Exiting process after debug file upload");
134
+ process.exit(0);
135
+ });
136
+ });
137
+ } };
138
+ };
28
139
  }
29
140
 
30
- var webpack4or5__namespace = /*#__PURE__*/_interopNamespace(webpack4or5);
31
-
32
- var _webpack4or5$default, _webpack4or5$default2;
33
- var BannerPlugin = (webpack4or5__namespace === null || webpack4or5__namespace === void 0 ? void 0 : webpack4or5__namespace.BannerPlugin) || (webpack4or5__namespace === null || webpack4or5__namespace === void 0 ? void 0 : (_webpack4or5$default = webpack4or5__namespace["default"]) === null || _webpack4or5$default === void 0 ? void 0 : _webpack4or5$default.BannerPlugin);
34
- var DefinePlugin = (webpack4or5__namespace === null || webpack4or5__namespace === void 0 ? void 0 : webpack4or5__namespace.DefinePlugin) || (webpack4or5__namespace === null || webpack4or5__namespace === void 0 ? void 0 : (_webpack4or5$default2 = webpack4or5__namespace["default"]) === null || _webpack4or5$default2 === void 0 ? void 0 : _webpack4or5$default2.DefinePlugin);
35
- var sentryUnplugin = webpack4and5.sentryWebpackUnpluginFactory({
36
- BannerPlugin: BannerPlugin,
37
- DefinePlugin: DefinePlugin
141
+ //#endregion
142
+ //#region src/index.ts
143
+ const BannerPlugin = webpack?.BannerPlugin || webpack?.default?.BannerPlugin;
144
+ const DefinePlugin = webpack?.DefinePlugin || webpack?.default?.DefinePlugin;
145
+ const sentryWebpackPlugin = sentryWebpackPluginFactory({
146
+ BannerPlugin,
147
+ DefinePlugin
38
148
  });
39
149
 
40
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
- var sentryWebpackPlugin = sentryUnplugin.webpack;
42
-
150
+ //#endregion
43
151
  Object.defineProperty(exports, 'sentryCliBinaryExists', {
44
152
  enumerable: true,
45
- get: function () { return bundlerPluginCore.sentryCliBinaryExists; }
153
+ get: function () {
154
+ return _sentry_bundler_plugin_core.sentryCliBinaryExists;
155
+ }
46
156
  });
47
157
  exports.sentryWebpackPlugin = sentryWebpackPlugin;
48
- //# sourceMappingURL=index.js.map
158
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import { SentryWebpackPluginOptions, sentryWebpackUnpluginFactory } from \"./webpack4and5\";\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore webpack is a peer dep\nimport * as webpack4or5 from \"webpack\";\n\nconst BannerPlugin = webpack4or5?.BannerPlugin || webpack4or5?.default?.BannerPlugin;\n\nconst DefinePlugin = webpack4or5?.DefinePlugin || webpack4or5?.default?.DefinePlugin;\n\nconst sentryUnplugin = sentryWebpackUnpluginFactory({\n BannerPlugin,\n DefinePlugin,\n});\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const sentryWebpackPlugin: (options?: SentryWebpackPluginOptions) => any =\n sentryUnplugin.webpack;\n\nexport { sentryCliBinaryExists } from \"@sentry/bundler-plugin-core\";\n\nexport type { SentryWebpackPluginOptions };\n"],"names":["BannerPlugin","webpack4or5","_webpack4or5$default","DefinePlugin","_webpack4or5$default2","sentryUnplugin","sentryWebpackUnpluginFactory","sentryWebpackPlugin","webpack"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAMA,YAAY,GAAG,CAAAC,sBAAW,KAAA,IAAA,IAAXA,sBAAW,KAAXA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,sBAAW,CAAED,YAAY,MAAIC,sBAAW,aAAXA,sBAAW,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,CAAAC,oBAAA,GAAXD,sBAAW,CAAA,SAAA,CAAS,cAAAC,oBAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAApBA,oBAAA,CAAsBF,YAAY,CAAA,CAAA;AAEpF,IAAMG,YAAY,GAAG,CAAAF,sBAAW,KAAA,IAAA,IAAXA,sBAAW,KAAXA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,sBAAW,CAAEE,YAAY,MAAIF,sBAAW,aAAXA,sBAAW,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,CAAAG,qBAAA,GAAXH,sBAAW,CAAA,SAAA,CAAS,cAAAG,qBAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAApBA,qBAAA,CAAsBD,YAAY,CAAA,CAAA;AAEpF,IAAME,cAAc,GAAGC,yCAA4B,CAAC;AAClDN,EAAAA,YAAY,EAAZA,YAAY;AACZG,EAAAA,YAAY,EAAZA,YAAAA;AACF,CAAC,CAAC,CAAA;;AAEF;AACaI,IAAAA,mBAAkE,GAC7EF,cAAc,CAACG;;;;;;;;"}
1
+ {"version":3,"file":"index.js","names":["path","CodeInjection","webpack4or5"],"sources":["../../src/webpack4and5.ts","../../src/index.ts"],"sourcesContent":["import {\n Options,\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n stringToUUID,\n createComponentNameAnnotateHooks,\n CodeInjection,\n getDebugIdSnippet,\n createDebugIdUploadFunction,\n} from \"@sentry/bundler-plugin-core\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { createRequire } from \"node:module\";\nimport { v4 as uuidv4 } from \"uuid\";\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore Rollup transpiles import.meta for us for CJS\nconst dirname = path.dirname(fileURLToPath(import.meta.url));\n\nconst COMPONENT_ANNOTATION_LOADER = path.resolve(\n dirname,\n typeof __dirname !== \"undefined\"\n ? \"component-annotation-transform.js\" // CJS\n : \"component-annotation-transform.mjs\" // ESM\n);\n\n// since webpack 5.1 compiler contains webpack module so plugins always use correct webpack version\n// https://github.com/webpack/webpack/commit/65eca2e529ce1d79b79200d4bdb1ce1b81141459\n\ninterface BannerPluginCallbackArg {\n chunk?: {\n hash?: string;\n contentHash?: {\n javascript?: string;\n };\n };\n}\n\ntype UnsafeBannerPlugin = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (options: any): unknown;\n};\n\ntype UnsafeDefinePlugin = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (options: any): unknown;\n};\n\ntype WebpackModule = {\n resource?: string;\n};\n\ntype WebpackLoaderCallback = (err: Error | null, content?: string, sourceMap?: unknown) => void;\n\ntype WebpackLoaderContext = {\n callback: WebpackLoaderCallback;\n};\n\ntype WebpackCompilationContext = {\n compiler: {\n webpack?: {\n NormalModule?: {\n getCompilationHooks: (compilation: WebpackCompilationContext) => {\n loader: {\n tap: (\n name: string,\n callback: (loaderContext: WebpackLoaderContext, module: WebpackModule) => void\n ) => void;\n };\n };\n };\n };\n };\n hooks: {\n normalModuleLoader?: {\n tap: (\n name: string,\n callback: (loaderContext: WebpackLoaderContext, module: WebpackModule) => void\n ) => void;\n };\n };\n};\n\ntype WebpackCompiler = {\n options: {\n plugins?: unknown[];\n mode?: string;\n module?: {\n rules?: unknown[];\n };\n };\n hooks: {\n thisCompilation: {\n tap: (name: string, callback: (compilation: WebpackCompilationContext) => void) => void;\n };\n afterEmit: {\n tapAsync: (\n name: string,\n callback: (compilation: WebpackCompilation, cb: () => void) => void\n ) => void;\n };\n done: {\n tap: (name: string, callback: () => void) => void;\n };\n };\n webpack?: {\n BannerPlugin?: UnsafeBannerPlugin;\n DefinePlugin?: UnsafeDefinePlugin;\n };\n};\n\ntype WebpackCompilation = {\n outputOptions: {\n path?: string;\n };\n assets: Record<string, unknown>;\n hooks: {\n processAssets: {\n tap: (options: { name: string; stage: number }, callback: () => void) => void;\n };\n };\n};\n\n// Detect webpack major version for telemetry (helps differentiate webpack 4 vs 5 usage)\nfunction getWebpackMajorVersion(): 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 webpack = req(\"webpack\") as { version?: string; default?: { version?: string } };\n const version = webpack?.version ?? webpack?.default?.version;\n const webpackMajorVersion = version?.split(\".\")[0]; // \"4\" or \"5\"\n return webpackMajorVersion;\n } catch (error) {\n return undefined;\n }\n}\n\n/**\n * The factory function accepts BannerPlugin and DefinePlugin classes in\n * order to avoid direct dependencies on webpack.\n *\n * This allow us to export version of the plugin for webpack 5.1+ and compatible environments.\n *\n * Since webpack 5.1 compiler contains webpack module so plugins always use correct webpack version.\n */\nexport function sentryWebpackPluginFactory({\n BannerPlugin: UnsafeBannerPlugin,\n DefinePlugin: UnsafeDefinePlugin,\n}: {\n BannerPlugin?: UnsafeBannerPlugin;\n DefinePlugin?: UnsafeDefinePlugin;\n} = {}) {\n return function sentryWebpackPlugin(userOptions: SentryWebpackPluginOptions = {}) {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? \"[sentry-webpack-plugin]\",\n buildTool: \"webpack\",\n buildToolMajorVersion: getWebpackMajorVersion(),\n });\n\n const {\n logger,\n normalizedOptions: options,\n bundleSizeOptimizationReplacementValues: replacementValues,\n bundleMetadata,\n createDependencyOnBuildArtifacts,\n } = sentryBuildPluginManager;\n\n if (options.disable) {\n return {\n apply() {\n // noop plugin\n },\n };\n }\n\n if (process.cwd().match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n logger.warn(\n \"Running Sentry plugin from within a `node_modules` folder. Some features may not work.\"\n );\n }\n\n const sourcemapsEnabled = options.sourcemaps?.disable !== true;\n const staticInjectionCode = new CodeInjection();\n\n if (!options.release.inject) {\n logger.debug(\n \"Release injection disabled via `release.inject` option. Will not inject release.\"\n );\n } else if (!options.release.name) {\n logger.debug(\n \"No release name provided. Will not inject release. Please set the `release.name` option to identify your release.\"\n );\n } else {\n staticInjectionCode.append(\n generateReleaseInjectorCode({\n release: options.release.name,\n injectBuildInformation: options._experiments.injectBuildInformation || false,\n })\n );\n }\n\n if (Object.keys(bundleMetadata).length > 0) {\n staticInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));\n }\n\n const transformAnnotations = options.reactComponentAnnotation?.enabled\n ? createComponentNameAnnotateHooks(\n options.reactComponentAnnotation?.ignoredComponents || [],\n !!options.reactComponentAnnotation?._experimentalInjectIntoHtml\n )\n : undefined;\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n\n return {\n apply(compiler: WebpackCompiler) {\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n\n // Get the correct plugin classes (webpack 5.1+ vs older versions)\n const BannerPlugin = compiler?.webpack?.BannerPlugin || UnsafeBannerPlugin;\n const DefinePlugin = compiler?.webpack?.DefinePlugin || UnsafeDefinePlugin;\n\n // Add BannerPlugin for code injection (release, metadata, debug IDs)\n if (!staticInjectionCode.isEmpty() || sourcemapsEnabled) {\n if (!BannerPlugin) {\n logger.warn(\n \"BannerPlugin is not available. Skipping code injection. This usually means webpack is not properly configured.\"\n );\n } else {\n compiler.options.plugins = compiler.options.plugins || [];\n compiler.options.plugins.push(\n new BannerPlugin({\n raw: true,\n include: /\\.(js|ts|jsx|tsx|mjs|cjs)(\\?[^?]*)?(#[^#]*)?$/,\n banner: (arg?: BannerPluginCallbackArg) => {\n const codeToInject = staticInjectionCode.clone();\n if (sourcemapsEnabled) {\n const hash = arg?.chunk?.contentHash?.javascript ?? arg?.chunk?.hash;\n const debugId = hash ? stringToUUID(hash) : uuidv4();\n codeToInject.append(getDebugIdSnippet(debugId));\n }\n return codeToInject.code();\n },\n })\n );\n }\n }\n\n // Add DefinePlugin for bundle size optimizations\n if (transformReplace && DefinePlugin) {\n compiler.options.plugins = compiler.options.plugins || [];\n compiler.options.plugins.push(new DefinePlugin(replacementValues));\n }\n\n // Add component name annotation transform\n if (transformAnnotations?.transform) {\n compiler.options.module = compiler.options.module || {};\n compiler.options.module.rules = compiler.options.module.rules || [];\n compiler.options.module.rules.unshift({\n test: /\\.[jt]sx$/,\n exclude: /node_modules/,\n enforce: \"pre\",\n use: [\n {\n loader: COMPONENT_ANNOTATION_LOADER,\n options: {\n transform: transformAnnotations.transform,\n },\n },\n ],\n });\n }\n\n compiler.hooks.afterEmit.tapAsync(\n \"sentry-webpack-plugin\",\n (compilation: WebpackCompilation, callback: () => void) => {\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n\n void sentryBuildPluginManager\n .createRelease()\n .then(async () => {\n if (sourcemapsEnabled && options.sourcemaps?.disable !== \"disable-upload\") {\n const outputPath = compilation.outputOptions.path ?? path.resolve();\n const buildArtifacts = Object.keys(compilation.assets).map((asset) =>\n path.join(outputPath, asset)\n );\n await upload(buildArtifacts);\n }\n })\n .then(() => {\n callback();\n })\n .finally(() => {\n freeGlobalDependencyOnBuildArtifacts();\n void sentryBuildPluginManager.deleteArtifacts();\n });\n }\n );\n\n if (\n userOptions._experiments?.forceExitOnBuildCompletion &&\n compiler.options.mode === \"production\"\n ) {\n compiler.hooks.done.tap(\"sentry-webpack-plugin\", () => {\n setTimeout(() => {\n logger.debug(\"Exiting process after debug file upload\");\n process.exit(0);\n });\n });\n }\n },\n };\n };\n}\n\nexport type SentryWebpackPluginOptions = Options & {\n _experiments?: Options[\"_experiments\"] & {\n /**\n * If enabled, the webpack plugin will exit the build process after the build completes.\n * Use this with caution, as it will terminate the process.\n *\n * More information: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/345\n *\n * @default false\n */\n forceExitOnBuildCompletion?: boolean;\n };\n};\n","import { SentryWebpackPluginOptions, sentryWebpackPluginFactory } from \"./webpack4and5\";\nimport * as webpack4or5 from \"webpack\";\n\nconst BannerPlugin = webpack4or5?.BannerPlugin || webpack4or5?.default?.BannerPlugin;\n\nconst DefinePlugin = webpack4or5?.DefinePlugin || webpack4or5?.default?.DefinePlugin;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const sentryWebpackPlugin: (options?: SentryWebpackPluginOptions) => any =\n sentryWebpackPluginFactory({\n BannerPlugin,\n DefinePlugin,\n });\n\nexport { sentryCliBinaryExists } from \"@sentry/bundler-plugin-core\";\n\nexport type { SentryWebpackPluginOptions };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAM,UAAUA,UAAK,kFAAsC,CAAC;AAE5D,MAAM,8BAA8BA,UAAK,QACvC,SACA,OAAO,cAAc,cACjB,sCACA,qCACL;AAoGD,SAAS,yBAA6C;AACpD,KAAI;EAIF,MAAM,uFADoC,CACtB,UAAU;AAG9B,UAFgB,SAAS,WAAW,SAAS,SAAS,UACjB,MAAM,IAAI,CAAC;UAEzC,OAAO;AACd;;;;;;;;;;;AAYJ,SAAgB,2BAA2B,EACzC,cAAc,oBACd,cAAc,uBAIZ,EAAE,EAAE;AACN,QAAO,SAAS,oBAAoB,cAA0C,EAAE,EAAE;EAChF,MAAM,2FAA0D,aAAa;GAC3E,cAAc,YAAY,cAAc,wBAAwB;GAChE,WAAW;GACX,uBAAuB,wBAAwB;GAChD,CAAC;EAEF,MAAM,EACJ,QACA,mBAAmB,SACnB,yCAAyC,mBACzC,gBACA,qCACE;AAEJ,MAAI,QAAQ,QACV,QAAO,EACL,QAAQ,IAGT;AAGH,MAAI,QAAQ,KAAK,CAAC,MAAM,oCAAoC,CAC1D,QAAO,KACL,yFACD;EAGH,MAAM,oBAAoB,QAAQ,YAAY,YAAY;EAC1D,MAAM,sBAAsB,IAAIC,2CAAe;AAE/C,MAAI,CAAC,QAAQ,QAAQ,OACnB,QAAO,MACL,mFACD;WACQ,CAAC,QAAQ,QAAQ,KAC1B,QAAO,MACL,oHACD;MAED,qBAAoB,oEACU;GAC1B,SAAS,QAAQ,QAAQ;GACzB,wBAAwB,QAAQ,aAAa,0BAA0B;GACxE,CAAC,CACH;AAGH,M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;MACR,SAAS,EACP,WAAW,qBAAqB,WACjC;MACF,CACF;KACF,CAAC;;AAGJ,YAAS,MAAM,UAAU,SACvB,0BACC,aAAiC,aAAyB;IACzD,MAAM,uCAAuC,kCAAkC;IAC/E,MAAM,sEAAqC,EAAE,0BAA0B,CAAC;AAExE,IAAK,yBACF,eAAe,CACf,KAAK,YAAY;AAChB,SAAI,qBAAqB,QAAQ,YAAY,YAAY,kBAAkB;MACzE,MAAM,aAAa,YAAY,cAAc,QAAQD,UAAK,SAAS;AAInE,YAAM,OAHiB,OAAO,KAAK,YAAY,OAAO,CAAC,KAAK,UAC1DA,UAAK,KAAK,YAAY,MAAM,CAC7B,CAC2B;;MAE9B,CACD,WAAW;AACV,eAAU;MACV,CACD,cAAc;AACb,2CAAsC;AACtC,KAAK,yBAAyB,iBAAiB;MAC/C;KAEP;AAED,OACE,YAAY,cAAc,8BAC1B,SAAS,QAAQ,SAAS,aAE1B,UAAS,MAAM,KAAK,IAAI,+BAA+B;AACrD,qBAAiB;AACf,YAAO,MAAM,0CAA0C;AACvD,aAAQ,KAAK,EAAE;MACf;KACF;KAGP;;;;;;ACzTL,MAAM,eAAeE,SAAa,gBAAgBA,SAAa,SAAS;AAExE,MAAM,eAAeA,SAAa,gBAAgBA,SAAa,SAAS;AAGxE,MAAa,sBACX,2BAA2B;CACzB;CACA;CACD,CAAC"}
@@ -0,0 +1,20 @@
1
+ //#region src/component-annotation-transform.ts
2
+ async function transform(source, map) {
3
+ const callback = this.async();
4
+ const { transform: transformFn } = this.query;
5
+ if (!transformFn) return callback(null, source, map);
6
+ try {
7
+ const id = this.resourcePath;
8
+ const result = await transformFn(source, id);
9
+ if (result == null) callback(null, source, map);
10
+ else if (typeof result === "string") callback(null, result, map);
11
+ else callback(null, result.code, result.map || map);
12
+ } catch (error) {
13
+ if (error instanceof Error) callback(error);
14
+ else callback(new Error(String(error)));
15
+ }
16
+ }
17
+
18
+ //#endregion
19
+ export { transform as default };
20
+ //# sourceMappingURL=component-annotation-transform.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-annotation-transform.mjs","names":[],"sources":["../../src/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?: (\n code: string,\n id: string\n ) => 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,UAW5B,QACA,KACe;CACf,MAAM,WAAW,KAAK,OAAO;CAC7B,MAAM,EAAE,WAAW,gBAAgB,KAAK;AAExC,KAAI,CAAC,YACH,QAAO,SAAS,MAAM,QAAQ,IAAI;AAGpC,KAAI;EACF,MAAM,KAAK,KAAK;EAChB,MAAM,SAAS,MAAM,YAAY,QAAQ,GAAG;AAE5C,MAAI,UAAU,KACZ,UAAS,MAAM,QAAQ,IAAI;WAClB,OAAO,WAAW,SAC3B,UAAS,MAAM,QAAQ,IAAI;MAE3B,UAAS,MAAM,OAAO,MAAM,OAAO,OAAO,IAAI;UAEzC,OAAO;AACd,MAAI,iBAAiB,MACnB,UAAS,MAAM;MAEf,UAAS,IAAI,MAAM,OAAO,MAAM,CAAC,CAAC"}
@@ -1,20 +1,122 @@
1
- import { s as sentryWebpackUnpluginFactory } from './webpack4and5.mjs';
2
- import * as webpack4or5 from 'webpack';
3
- export { sentryCliBinaryExists } from '@sentry/bundler-plugin-core';
4
- import 'node:module';
5
- import 'path';
6
- import 'uuid';
1
+ import { createRequire } from "node:module";
2
+ import { CodeInjection, createComponentNameAnnotateHooks, createDebugIdUploadFunction, createSentryBuildPluginManager, generateModuleMetadataInjectorCode, generateReleaseInjectorCode, getDebugIdSnippet, sentryCliBinaryExists, stringToUUID } from "@sentry/bundler-plugin-core";
3
+ import * as path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { v4 } from "uuid";
6
+ import * as webpack4or5 from "webpack";
7
7
 
8
- var _webpack4or5$default, _webpack4or5$default2;
9
- var BannerPlugin = (webpack4or5 === null || webpack4or5 === void 0 ? void 0 : webpack4or5.BannerPlugin) || (webpack4or5 === null || webpack4or5 === void 0 ? void 0 : (_webpack4or5$default = webpack4or5["default"]) === null || _webpack4or5$default === void 0 ? void 0 : _webpack4or5$default.BannerPlugin);
10
- var DefinePlugin = (webpack4or5 === null || webpack4or5 === void 0 ? void 0 : webpack4or5.DefinePlugin) || (webpack4or5 === null || webpack4or5 === void 0 ? void 0 : (_webpack4or5$default2 = webpack4or5["default"]) === null || _webpack4or5$default2 === void 0 ? void 0 : _webpack4or5$default2.DefinePlugin);
11
- var sentryUnplugin = sentryWebpackUnpluginFactory({
12
- BannerPlugin: BannerPlugin,
13
- DefinePlugin: DefinePlugin
14
- });
8
+ //#region src/webpack4and5.ts
9
+ const dirname = path.dirname(fileURLToPath(import.meta.url));
10
+ const COMPONENT_ANNOTATION_LOADER = path.resolve(dirname, typeof __dirname !== "undefined" ? "component-annotation-transform.js" : "component-annotation-transform.mjs");
11
+ function getWebpackMajorVersion() {
12
+ try {
13
+ const webpack = createRequire(import.meta.url)("webpack");
14
+ return (webpack?.version ?? webpack?.default?.version)?.split(".")[0];
15
+ } catch (error) {
16
+ return;
17
+ }
18
+ }
19
+ /**
20
+ * The factory function accepts BannerPlugin and DefinePlugin classes in
21
+ * order to avoid direct dependencies on webpack.
22
+ *
23
+ * This allow us to export version of the plugin for webpack 5.1+ and compatible environments.
24
+ *
25
+ * Since webpack 5.1 compiler contains webpack module so plugins always use correct webpack version.
26
+ */
27
+ function sentryWebpackPluginFactory({ BannerPlugin: UnsafeBannerPlugin, DefinePlugin: UnsafeDefinePlugin } = {}) {
28
+ return function sentryWebpackPlugin(userOptions = {}) {
29
+ const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {
30
+ loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? "[sentry-webpack-plugin]",
31
+ buildTool: "webpack",
32
+ buildToolMajorVersion: getWebpackMajorVersion()
33
+ });
34
+ const { logger, normalizedOptions: options, bundleSizeOptimizationReplacementValues: replacementValues, bundleMetadata, createDependencyOnBuildArtifacts } = sentryBuildPluginManager;
35
+ if (options.disable) return { apply() {} };
36
+ if (process.cwd().match(/\\node_modules\\|\/node_modules\//)) logger.warn("Running Sentry plugin from within a `node_modules` folder. Some features may not work.");
37
+ const sourcemapsEnabled = options.sourcemaps?.disable !== true;
38
+ const staticInjectionCode = new CodeInjection();
39
+ if (!options.release.inject) logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
40
+ 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.");
41
+ else staticInjectionCode.append(generateReleaseInjectorCode({
42
+ release: options.release.name,
43
+ injectBuildInformation: options._experiments.injectBuildInformation || false
44
+ }));
45
+ if (Object.keys(bundleMetadata).length > 0) staticInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));
46
+ const transformAnnotations = options.reactComponentAnnotation?.enabled ? createComponentNameAnnotateHooks(options.reactComponentAnnotation?.ignoredComponents || [], !!options.reactComponentAnnotation?._experimentalInjectIntoHtml) : void 0;
47
+ const transformReplace = Object.keys(replacementValues).length > 0;
48
+ return { apply(compiler) {
49
+ sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {});
50
+ const BannerPlugin = compiler?.webpack?.BannerPlugin || UnsafeBannerPlugin;
51
+ const DefinePlugin = compiler?.webpack?.DefinePlugin || UnsafeDefinePlugin;
52
+ if (!staticInjectionCode.isEmpty() || sourcemapsEnabled) if (!BannerPlugin) logger.warn("BannerPlugin is not available. Skipping code injection. This usually means webpack is not properly configured.");
53
+ else {
54
+ compiler.options.plugins = compiler.options.plugins || [];
55
+ compiler.options.plugins.push(new BannerPlugin({
56
+ raw: true,
57
+ include: /\.(js|ts|jsx|tsx|mjs|cjs)(\?[^?]*)?(#[^#]*)?$/,
58
+ banner: (arg) => {
59
+ const codeToInject = staticInjectionCode.clone();
60
+ if (sourcemapsEnabled) {
61
+ const hash = arg?.chunk?.contentHash?.javascript ?? arg?.chunk?.hash;
62
+ const debugId = hash ? stringToUUID(hash) : v4();
63
+ codeToInject.append(getDebugIdSnippet(debugId));
64
+ }
65
+ return codeToInject.code();
66
+ }
67
+ }));
68
+ }
69
+ if (transformReplace && DefinePlugin) {
70
+ compiler.options.plugins = compiler.options.plugins || [];
71
+ compiler.options.plugins.push(new DefinePlugin(replacementValues));
72
+ }
73
+ if (transformAnnotations?.transform) {
74
+ compiler.options.module = compiler.options.module || {};
75
+ compiler.options.module.rules = compiler.options.module.rules || [];
76
+ compiler.options.module.rules.unshift({
77
+ test: /\.[jt]sx$/,
78
+ exclude: /node_modules/,
79
+ enforce: "pre",
80
+ use: [{
81
+ loader: COMPONENT_ANNOTATION_LOADER,
82
+ options: { transform: transformAnnotations.transform }
83
+ }]
84
+ });
85
+ }
86
+ compiler.hooks.afterEmit.tapAsync("sentry-webpack-plugin", (compilation, callback) => {
87
+ const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
88
+ const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });
89
+ sentryBuildPluginManager.createRelease().then(async () => {
90
+ if (sourcemapsEnabled && options.sourcemaps?.disable !== "disable-upload") {
91
+ const outputPath = compilation.outputOptions.path ?? path.resolve();
92
+ await upload(Object.keys(compilation.assets).map((asset) => path.join(outputPath, asset)));
93
+ }
94
+ }).then(() => {
95
+ callback();
96
+ }).finally(() => {
97
+ freeGlobalDependencyOnBuildArtifacts();
98
+ sentryBuildPluginManager.deleteArtifacts();
99
+ });
100
+ });
101
+ if (userOptions._experiments?.forceExitOnBuildCompletion && compiler.options.mode === "production") compiler.hooks.done.tap("sentry-webpack-plugin", () => {
102
+ setTimeout(() => {
103
+ logger.debug("Exiting process after debug file upload");
104
+ process.exit(0);
105
+ });
106
+ });
107
+ } };
108
+ };
109
+ }
15
110
 
16
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
- var sentryWebpackPlugin = sentryUnplugin.webpack;
111
+ //#endregion
112
+ //#region src/index.ts
113
+ const BannerPlugin = webpack4or5?.BannerPlugin || webpack4or5?.default?.BannerPlugin;
114
+ const DefinePlugin = webpack4or5?.DefinePlugin || webpack4or5?.default?.DefinePlugin;
115
+ const sentryWebpackPlugin = sentryWebpackPluginFactory({
116
+ BannerPlugin,
117
+ DefinePlugin
118
+ });
18
119
 
19
- export { sentryWebpackPlugin };
20
- //# sourceMappingURL=index.mjs.map
120
+ //#endregion
121
+ export { sentryCliBinaryExists, sentryWebpackPlugin };
122
+ //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/index.ts"],"sourcesContent":["import { SentryWebpackPluginOptions, sentryWebpackUnpluginFactory } from \"./webpack4and5\";\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore webpack is a peer dep\nimport * as webpack4or5 from \"webpack\";\n\nconst BannerPlugin = webpack4or5?.BannerPlugin || webpack4or5?.default?.BannerPlugin;\n\nconst DefinePlugin = webpack4or5?.DefinePlugin || webpack4or5?.default?.DefinePlugin;\n\nconst sentryUnplugin = sentryWebpackUnpluginFactory({\n BannerPlugin,\n DefinePlugin,\n});\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const sentryWebpackPlugin: (options?: SentryWebpackPluginOptions) => any =\n sentryUnplugin.webpack;\n\nexport { sentryCliBinaryExists } from \"@sentry/bundler-plugin-core\";\n\nexport type { SentryWebpackPluginOptions };\n"],"names":["BannerPlugin","webpack4or5","_webpack4or5$default","DefinePlugin","_webpack4or5$default2","sentryUnplugin","sentryWebpackUnpluginFactory","sentryWebpackPlugin","webpack"],"mappings":";;;;;;;;AAMA,IAAMA,YAAY,GAAG,CAAAC,WAAW,KAAA,IAAA,IAAXA,WAAW,KAAXA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,WAAW,CAAED,YAAY,MAAIC,WAAW,aAAXA,WAAW,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,CAAAC,oBAAA,GAAXD,WAAW,CAAA,SAAA,CAAS,cAAAC,oBAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAApBA,oBAAA,CAAsBF,YAAY,CAAA,CAAA;AAEpF,IAAMG,YAAY,GAAG,CAAAF,WAAW,KAAA,IAAA,IAAXA,WAAW,KAAXA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,WAAW,CAAEE,YAAY,MAAIF,WAAW,aAAXA,WAAW,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,CAAAG,qBAAA,GAAXH,WAAW,CAAA,SAAA,CAAS,cAAAG,qBAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAApBA,qBAAA,CAAsBD,YAAY,CAAA,CAAA;AAEpF,IAAME,cAAc,GAAGC,4BAA4B,CAAC;AAClDN,EAAAA,YAAY,EAAZA,YAAY;AACZG,EAAAA,YAAY,EAAZA,YAAAA;AACF,CAAC,CAAC,CAAA;;AAEF;AACaI,IAAAA,mBAAkE,GAC7EF,cAAc,CAACG;;;;"}
1
+ {"version":3,"file":"index.mjs","names":["uuidv4"],"sources":["../../src/webpack4and5.ts","../../src/index.ts"],"sourcesContent":["import {\n Options,\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n stringToUUID,\n createComponentNameAnnotateHooks,\n CodeInjection,\n getDebugIdSnippet,\n createDebugIdUploadFunction,\n} from \"@sentry/bundler-plugin-core\";\nimport * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { createRequire } from \"node:module\";\nimport { v4 as uuidv4 } from \"uuid\";\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore Rollup transpiles import.meta for us for CJS\nconst dirname = path.dirname(fileURLToPath(import.meta.url));\n\nconst COMPONENT_ANNOTATION_LOADER = path.resolve(\n dirname,\n typeof __dirname !== \"undefined\"\n ? \"component-annotation-transform.js\" // CJS\n : \"component-annotation-transform.mjs\" // ESM\n);\n\n// since webpack 5.1 compiler contains webpack module so plugins always use correct webpack version\n// https://github.com/webpack/webpack/commit/65eca2e529ce1d79b79200d4bdb1ce1b81141459\n\ninterface BannerPluginCallbackArg {\n chunk?: {\n hash?: string;\n contentHash?: {\n javascript?: string;\n };\n };\n}\n\ntype UnsafeBannerPlugin = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (options: any): unknown;\n};\n\ntype UnsafeDefinePlugin = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (options: any): unknown;\n};\n\ntype WebpackModule = {\n resource?: string;\n};\n\ntype WebpackLoaderCallback = (err: Error | null, content?: string, sourceMap?: unknown) => void;\n\ntype WebpackLoaderContext = {\n callback: WebpackLoaderCallback;\n};\n\ntype WebpackCompilationContext = {\n compiler: {\n webpack?: {\n NormalModule?: {\n getCompilationHooks: (compilation: WebpackCompilationContext) => {\n loader: {\n tap: (\n name: string,\n callback: (loaderContext: WebpackLoaderContext, module: WebpackModule) => void\n ) => void;\n };\n };\n };\n };\n };\n hooks: {\n normalModuleLoader?: {\n tap: (\n name: string,\n callback: (loaderContext: WebpackLoaderContext, module: WebpackModule) => void\n ) => void;\n };\n };\n};\n\ntype WebpackCompiler = {\n options: {\n plugins?: unknown[];\n mode?: string;\n module?: {\n rules?: unknown[];\n };\n };\n hooks: {\n thisCompilation: {\n tap: (name: string, callback: (compilation: WebpackCompilationContext) => void) => void;\n };\n afterEmit: {\n tapAsync: (\n name: string,\n callback: (compilation: WebpackCompilation, cb: () => void) => void\n ) => void;\n };\n done: {\n tap: (name: string, callback: () => void) => void;\n };\n };\n webpack?: {\n BannerPlugin?: UnsafeBannerPlugin;\n DefinePlugin?: UnsafeDefinePlugin;\n };\n};\n\ntype WebpackCompilation = {\n outputOptions: {\n path?: string;\n };\n assets: Record<string, unknown>;\n hooks: {\n processAssets: {\n tap: (options: { name: string; stage: number }, callback: () => void) => void;\n };\n };\n};\n\n// Detect webpack major version for telemetry (helps differentiate webpack 4 vs 5 usage)\nfunction getWebpackMajorVersion(): 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 webpack = req(\"webpack\") as { version?: string; default?: { version?: string } };\n const version = webpack?.version ?? webpack?.default?.version;\n const webpackMajorVersion = version?.split(\".\")[0]; // \"4\" or \"5\"\n return webpackMajorVersion;\n } catch (error) {\n return undefined;\n }\n}\n\n/**\n * The factory function accepts BannerPlugin and DefinePlugin classes in\n * order to avoid direct dependencies on webpack.\n *\n * This allow us to export version of the plugin for webpack 5.1+ and compatible environments.\n *\n * Since webpack 5.1 compiler contains webpack module so plugins always use correct webpack version.\n */\nexport function sentryWebpackPluginFactory({\n BannerPlugin: UnsafeBannerPlugin,\n DefinePlugin: UnsafeDefinePlugin,\n}: {\n BannerPlugin?: UnsafeBannerPlugin;\n DefinePlugin?: UnsafeDefinePlugin;\n} = {}) {\n return function sentryWebpackPlugin(userOptions: SentryWebpackPluginOptions = {}) {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? \"[sentry-webpack-plugin]\",\n buildTool: \"webpack\",\n buildToolMajorVersion: getWebpackMajorVersion(),\n });\n\n const {\n logger,\n normalizedOptions: options,\n bundleSizeOptimizationReplacementValues: replacementValues,\n bundleMetadata,\n createDependencyOnBuildArtifacts,\n } = sentryBuildPluginManager;\n\n if (options.disable) {\n return {\n apply() {\n // noop plugin\n },\n };\n }\n\n if (process.cwd().match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n logger.warn(\n \"Running Sentry plugin from within a `node_modules` folder. Some features may not work.\"\n );\n }\n\n const sourcemapsEnabled = options.sourcemaps?.disable !== true;\n const staticInjectionCode = new CodeInjection();\n\n if (!options.release.inject) {\n logger.debug(\n \"Release injection disabled via `release.inject` option. Will not inject release.\"\n );\n } else if (!options.release.name) {\n logger.debug(\n \"No release name provided. Will not inject release. Please set the `release.name` option to identify your release.\"\n );\n } else {\n staticInjectionCode.append(\n generateReleaseInjectorCode({\n release: options.release.name,\n injectBuildInformation: options._experiments.injectBuildInformation || false,\n })\n );\n }\n\n if (Object.keys(bundleMetadata).length > 0) {\n staticInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));\n }\n\n const transformAnnotations = options.reactComponentAnnotation?.enabled\n ? createComponentNameAnnotateHooks(\n options.reactComponentAnnotation?.ignoredComponents || [],\n !!options.reactComponentAnnotation?._experimentalInjectIntoHtml\n )\n : undefined;\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n\n return {\n apply(compiler: WebpackCompiler) {\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n\n // Get the correct plugin classes (webpack 5.1+ vs older versions)\n const BannerPlugin = compiler?.webpack?.BannerPlugin || UnsafeBannerPlugin;\n const DefinePlugin = compiler?.webpack?.DefinePlugin || UnsafeDefinePlugin;\n\n // Add BannerPlugin for code injection (release, metadata, debug IDs)\n if (!staticInjectionCode.isEmpty() || sourcemapsEnabled) {\n if (!BannerPlugin) {\n logger.warn(\n \"BannerPlugin is not available. Skipping code injection. This usually means webpack is not properly configured.\"\n );\n } else {\n compiler.options.plugins = compiler.options.plugins || [];\n compiler.options.plugins.push(\n new BannerPlugin({\n raw: true,\n include: /\\.(js|ts|jsx|tsx|mjs|cjs)(\\?[^?]*)?(#[^#]*)?$/,\n banner: (arg?: BannerPluginCallbackArg) => {\n const codeToInject = staticInjectionCode.clone();\n if (sourcemapsEnabled) {\n const hash = arg?.chunk?.contentHash?.javascript ?? arg?.chunk?.hash;\n const debugId = hash ? stringToUUID(hash) : uuidv4();\n codeToInject.append(getDebugIdSnippet(debugId));\n }\n return codeToInject.code();\n },\n })\n );\n }\n }\n\n // Add DefinePlugin for bundle size optimizations\n if (transformReplace && DefinePlugin) {\n compiler.options.plugins = compiler.options.plugins || [];\n compiler.options.plugins.push(new DefinePlugin(replacementValues));\n }\n\n // Add component name annotation transform\n if (transformAnnotations?.transform) {\n compiler.options.module = compiler.options.module || {};\n compiler.options.module.rules = compiler.options.module.rules || [];\n compiler.options.module.rules.unshift({\n test: /\\.[jt]sx$/,\n exclude: /node_modules/,\n enforce: \"pre\",\n use: [\n {\n loader: COMPONENT_ANNOTATION_LOADER,\n options: {\n transform: transformAnnotations.transform,\n },\n },\n ],\n });\n }\n\n compiler.hooks.afterEmit.tapAsync(\n \"sentry-webpack-plugin\",\n (compilation: WebpackCompilation, callback: () => void) => {\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n\n void sentryBuildPluginManager\n .createRelease()\n .then(async () => {\n if (sourcemapsEnabled && options.sourcemaps?.disable !== \"disable-upload\") {\n const outputPath = compilation.outputOptions.path ?? path.resolve();\n const buildArtifacts = Object.keys(compilation.assets).map((asset) =>\n path.join(outputPath, asset)\n );\n await upload(buildArtifacts);\n }\n })\n .then(() => {\n callback();\n })\n .finally(() => {\n freeGlobalDependencyOnBuildArtifacts();\n void sentryBuildPluginManager.deleteArtifacts();\n });\n }\n );\n\n if (\n userOptions._experiments?.forceExitOnBuildCompletion &&\n compiler.options.mode === \"production\"\n ) {\n compiler.hooks.done.tap(\"sentry-webpack-plugin\", () => {\n setTimeout(() => {\n logger.debug(\"Exiting process after debug file upload\");\n process.exit(0);\n });\n });\n }\n },\n };\n };\n}\n\nexport type SentryWebpackPluginOptions = Options & {\n _experiments?: Options[\"_experiments\"] & {\n /**\n * If enabled, the webpack plugin will exit the build process after the build completes.\n * Use this with caution, as it will terminate the process.\n *\n * More information: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/345\n *\n * @default false\n */\n forceExitOnBuildCompletion?: boolean;\n };\n};\n","import { SentryWebpackPluginOptions, sentryWebpackPluginFactory } from \"./webpack4and5\";\nimport * as webpack4or5 from \"webpack\";\n\nconst BannerPlugin = webpack4or5?.BannerPlugin || webpack4or5?.default?.BannerPlugin;\n\nconst DefinePlugin = webpack4or5?.DefinePlugin || webpack4or5?.default?.DefinePlugin;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const sentryWebpackPlugin: (options?: SentryWebpackPluginOptions) => any =\n sentryWebpackPluginFactory({\n BannerPlugin,\n DefinePlugin,\n });\n\nexport { sentryCliBinaryExists } from \"@sentry/bundler-plugin-core\";\n\nexport type { SentryWebpackPluginOptions };\n"],"mappings":";;;;;;;;AAkBA,MAAM,UAAU,KAAK,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAE5D,MAAM,8BAA8B,KAAK,QACvC,SACA,OAAO,cAAc,cACjB,sCACA,qCACL;AAoGD,SAAS,yBAA6C;AACpD,KAAI;EAIF,MAAM,UADM,cAAc,OAAO,KAAK,IAAI,CACtB,UAAU;AAG9B,UAFgB,SAAS,WAAW,SAAS,SAAS,UACjB,MAAM,IAAI,CAAC;UAEzC,OAAO;AACd;;;;;;;;;;;AAYJ,SAAgB,2BAA2B,EACzC,cAAc,oBACd,cAAc,uBAIZ,EAAE,EAAE;AACN,QAAO,SAAS,oBAAoB,cAA0C,EAAE,EAAE;EAChF,MAAM,2BAA2B,+BAA+B,aAAa;GAC3E,cAAc,YAAY,cAAc,wBAAwB;GAChE,WAAW;GACX,uBAAuB,wBAAwB;GAChD,CAAC;EAEF,MAAM,EACJ,QACA,mBAAmB,SACnB,yCAAyC,mB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a,gBAAgB,aAAa,SAAS;AAGxE,MAAa,sBACX,2BAA2B;CACzB;CACA;CACD,CAAC"}
@@ -0,0 +1,10 @@
1
+ export default function transform(this: {
2
+ async: () => (err: Error | null, content?: string, sourceMap?: unknown) => void;
3
+ resourcePath: string;
4
+ query: {
5
+ transform?: (code: string, id: string) => Promise<{
6
+ code: string;
7
+ map?: unknown;
8
+ } | null | undefined | string>;
9
+ };
10
+ }, source: string, map: unknown): Promise<void>;
@@ -1,10 +1,73 @@
1
- import { Options, sentryUnpluginFactory } from "@sentry/bundler-plugin-core";
1
+ import { Options } from "@sentry/bundler-plugin-core";
2
2
  type UnsafeBannerPlugin = {
3
3
  new (options: any): unknown;
4
4
  };
5
5
  type UnsafeDefinePlugin = {
6
6
  new (options: any): unknown;
7
7
  };
8
+ type WebpackModule = {
9
+ resource?: string;
10
+ };
11
+ type WebpackLoaderCallback = (err: Error | null, content?: string, sourceMap?: unknown) => void;
12
+ type WebpackLoaderContext = {
13
+ callback: WebpackLoaderCallback;
14
+ };
15
+ type WebpackCompilationContext = {
16
+ compiler: {
17
+ webpack?: {
18
+ NormalModule?: {
19
+ getCompilationHooks: (compilation: WebpackCompilationContext) => {
20
+ loader: {
21
+ tap: (name: string, callback: (loaderContext: WebpackLoaderContext, module: WebpackModule) => void) => void;
22
+ };
23
+ };
24
+ };
25
+ };
26
+ };
27
+ hooks: {
28
+ normalModuleLoader?: {
29
+ tap: (name: string, callback: (loaderContext: WebpackLoaderContext, module: WebpackModule) => void) => void;
30
+ };
31
+ };
32
+ };
33
+ type WebpackCompiler = {
34
+ options: {
35
+ plugins?: unknown[];
36
+ mode?: string;
37
+ module?: {
38
+ rules?: unknown[];
39
+ };
40
+ };
41
+ hooks: {
42
+ thisCompilation: {
43
+ tap: (name: string, callback: (compilation: WebpackCompilationContext) => void) => void;
44
+ };
45
+ afterEmit: {
46
+ tapAsync: (name: string, callback: (compilation: WebpackCompilation, cb: () => void) => void) => void;
47
+ };
48
+ done: {
49
+ tap: (name: string, callback: () => void) => void;
50
+ };
51
+ };
52
+ webpack?: {
53
+ BannerPlugin?: UnsafeBannerPlugin;
54
+ DefinePlugin?: UnsafeDefinePlugin;
55
+ };
56
+ };
57
+ type WebpackCompilation = {
58
+ outputOptions: {
59
+ path?: string;
60
+ };
61
+ assets: Record<string, unknown>;
62
+ hooks: {
63
+ processAssets: {
64
+ tap: (options: {
65
+ name: string;
66
+ stage: number;
67
+ }, callback: () => void) => void;
68
+ };
69
+ };
70
+ };
8
71
  /**
9
72
  * The factory function accepts BannerPlugin and DefinePlugin classes in
10
73
  * order to avoid direct dependencies on webpack.
@@ -13,10 +76,12 @@ type UnsafeDefinePlugin = {
13
76
  *
14
77
  * Since webpack 5.1 compiler contains webpack module so plugins always use correct webpack version.
15
78
  */
16
- export declare function sentryWebpackUnpluginFactory({ BannerPlugin, DefinePlugin, }?: {
79
+ export declare function sentryWebpackPluginFactory({ BannerPlugin: UnsafeBannerPlugin, DefinePlugin: UnsafeDefinePlugin, }?: {
17
80
  BannerPlugin?: UnsafeBannerPlugin;
18
81
  DefinePlugin?: UnsafeDefinePlugin;
19
- }): ReturnType<typeof sentryUnpluginFactory>;
82
+ }): (userOptions?: SentryWebpackPluginOptions) => {
83
+ apply(compiler: WebpackCompiler): void;
84
+ };
20
85
  export type SentryWebpackPluginOptions = Options & {
21
86
  _experiments?: Options["_experiments"] & {
22
87
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/webpack-plugin",
3
- "version": "4.9.1",
3
+ "version": "5.1.0",
4
4
  "description": "Official Sentry Webpack plugin",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript-bundler-plugins.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript-bundler-plugins/tree/main/packages/webpack-plugin",
@@ -36,8 +36,8 @@
36
36
  "scripts": {
37
37
  "build": "premove ./dist && run-p build:rollup build:types",
38
38
  "build:watch": "run-p build:rollup:watch build:types:watch",
39
- "build:rollup": "rollup --config rollup.config.js",
40
- "build:rollup:watch": "rollup --config rollup.config.js --watch --no-watch.clearScreen",
39
+ "build:rollup": "rolldown --config rollup.config.mjs",
40
+ "build:rollup:watch": "rolldown --config rollup.config.mjs --watch --no-watch.clearScreen",
41
41
  "build:types": "tsc --project types.tsconfig.json",
42
42
  "build:types:watch": "tsc --project types.tsconfig.json --watch --preserveWatchOutput",
43
43
  "check:types": "run-p check:types:src check:types:test",
@@ -53,18 +53,12 @@
53
53
  "prepack": "ts-node ./src/prepack.ts"
54
54
  },
55
55
  "dependencies": {
56
- "@sentry/bundler-plugin-core": "4.9.1",
57
- "unplugin": "1.0.1",
56
+ "@sentry/bundler-plugin-core": "5.1.0",
58
57
  "uuid": "^9.0.0"
59
58
  },
60
59
  "devDependencies": {
61
- "@babel/core": "7.18.5",
62
- "@babel/preset-env": "7.18.2",
63
- "@babel/preset-typescript": "7.17.12",
64
- "@rollup/plugin-babel": "5.3.1",
65
- "@rollup/plugin-commonjs": "22.0.1",
66
- "@sentry-internal/eslint-config": "4.9.1",
67
- "@sentry-internal/sentry-bundler-plugin-tsconfig": "4.9.1",
60
+ "@sentry-internal/eslint-config": "5.1.0",
61
+ "@sentry-internal/sentry-bundler-plugin-tsconfig": "5.1.0",
68
62
  "@swc/core": "^1.2.205",
69
63
  "@swc/jest": "^0.2.21",
70
64
  "@types/jest": "^28.1.3",
@@ -74,13 +68,13 @@
74
68
  "eslint": "^8.18.0",
75
69
  "jest": "^28.1.1",
76
70
  "premove": "^4.0.0",
77
- "rollup": "2.79.2",
71
+ "rolldown": "^1.0.0-rc.4",
78
72
  "ts-node": "^10.9.1",
79
73
  "typescript": "^4.7.4",
80
- "webpack": "npm:webpack@^4"
74
+ "webpack": "5.0.0"
81
75
  },
82
76
  "peerDependencies": {
83
- "webpack": ">=4.40.0"
77
+ "webpack": ">=5.0.0"
84
78
  },
85
79
  "volta": {
86
80
  "extends": "../../package.json"
@@ -1,219 +0,0 @@
1
- 'use strict';
2
-
3
- var bundlerPluginCore = require('@sentry/bundler-plugin-core');
4
- var node_module = require('node:module');
5
- var path = require('path');
6
- var uuid = require('uuid');
7
-
8
- function _interopNamespace(e) {
9
- if (e && e.__esModule) return e;
10
- var n = Object.create(null);
11
- if (e) {
12
- Object.keys(e).forEach(function (k) {
13
- if (k !== 'default') {
14
- var d = Object.getOwnPropertyDescriptor(e, k);
15
- Object.defineProperty(n, k, d.get ? d : {
16
- enumerable: true,
17
- get: function () { return e[k]; }
18
- });
19
- }
20
- });
21
- }
22
- n["default"] = e;
23
- return Object.freeze(n);
24
- }
25
-
26
- var path__namespace = /*#__PURE__*/_interopNamespace(path);
27
-
28
- function ownKeys(object, enumerableOnly) {
29
- var keys = Object.keys(object);
30
- if (Object.getOwnPropertySymbols) {
31
- var symbols = Object.getOwnPropertySymbols(object);
32
- enumerableOnly && (symbols = symbols.filter(function (sym) {
33
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
34
- })), keys.push.apply(keys, symbols);
35
- }
36
- return keys;
37
- }
38
- function _objectSpread2(target) {
39
- for (var i = 1; i < arguments.length; i++) {
40
- var source = null != arguments[i] ? arguments[i] : {};
41
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
42
- _defineProperty(target, key, source[key]);
43
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
44
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
45
- });
46
- }
47
- return target;
48
- }
49
- function _defineProperty(obj, key, value) {
50
- key = _toPropertyKey(key);
51
- if (key in obj) {
52
- Object.defineProperty(obj, key, {
53
- value: value,
54
- enumerable: true,
55
- configurable: true,
56
- writable: true
57
- });
58
- } else {
59
- obj[key] = value;
60
- }
61
- return obj;
62
- }
63
- function _toPrimitive(input, hint) {
64
- if (typeof input !== "object" || input === null) return input;
65
- var prim = input[Symbol.toPrimitive];
66
- if (prim !== undefined) {
67
- var res = prim.call(input, hint || "default");
68
- if (typeof res !== "object") return res;
69
- throw new TypeError("@@toPrimitive must return a primitive value.");
70
- }
71
- return (hint === "string" ? String : Number)(input);
72
- }
73
- function _toPropertyKey(arg) {
74
- var key = _toPrimitive(arg, "string");
75
- return typeof key === "symbol" ? key : String(key);
76
- }
77
-
78
- // since webpack 5.1 compiler contains webpack module so plugins always use correct webpack version
79
- // https://github.com/webpack/webpack/commit/65eca2e529ce1d79b79200d4bdb1ce1b81141459
80
- function webpackInjectionPlugin(UnsafeBannerPlugin) {
81
- return function (injectionCode, debugIds) {
82
- return {
83
- name: "sentry-webpack-injection-plugin",
84
- webpack: function webpack(compiler) {
85
- var _compiler$webpack;
86
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
87
- // @ts-ignore webpack version compatibility shenanigans
88
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
89
- var BannerPlugin =
90
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
91
- // @ts-ignore webpack version compatibility shenanigans
92
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
93
- (compiler === null || compiler === void 0 ? void 0 : (_compiler$webpack = compiler.webpack) === null || _compiler$webpack === void 0 ? void 0 : _compiler$webpack.BannerPlugin) || UnsafeBannerPlugin;
94
- compiler.options.plugins = compiler.options.plugins || [];
95
- compiler.options.plugins.push(
96
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
97
- new BannerPlugin({
98
- raw: true,
99
- include: /\.(js|ts|jsx|tsx|mjs|cjs)(\?[^?]*)?(#[^#]*)?$/,
100
- banner: function banner(arg) {
101
- var codeToInject = injectionCode.clone();
102
- if (debugIds) {
103
- var _arg$chunk$contentHas, _arg$chunk, _arg$chunk$contentHas2, _arg$chunk2;
104
- var hash = (_arg$chunk$contentHas = arg === null || arg === void 0 ? void 0 : (_arg$chunk = arg.chunk) === null || _arg$chunk === void 0 ? void 0 : (_arg$chunk$contentHas2 = _arg$chunk.contentHash) === null || _arg$chunk$contentHas2 === void 0 ? void 0 : _arg$chunk$contentHas2.javascript) !== null && _arg$chunk$contentHas !== void 0 ? _arg$chunk$contentHas : arg === null || arg === void 0 ? void 0 : (_arg$chunk2 = arg.chunk) === null || _arg$chunk2 === void 0 ? void 0 : _arg$chunk2.hash;
105
- var debugId = hash ? bundlerPluginCore.stringToUUID(hash) : uuid.v4();
106
- codeToInject.append(bundlerPluginCore.getDebugIdSnippet(debugId));
107
- }
108
- return codeToInject.code();
109
- }
110
- }));
111
- }
112
- };
113
- };
114
- }
115
- function webpackComponentNameAnnotatePlugin() {
116
- return function (ignoredComponents, injectIntoHtml) {
117
- return {
118
- name: "sentry-webpack-component-name-annotate-plugin",
119
- enforce: "pre",
120
- // Webpack needs this hook for loader logic, so the plugin is not run on unsupported file types
121
- transformInclude: function transformInclude(id) {
122
- return id.endsWith(".tsx") || id.endsWith(".jsx");
123
- },
124
- transform: bundlerPluginCore.createComponentNameAnnotateHooks(ignoredComponents, injectIntoHtml).transform
125
- };
126
- };
127
- }
128
- function webpackBundleSizeOptimizationsPlugin(UnsafeDefinePlugin) {
129
- return function (replacementValues) {
130
- return {
131
- name: "sentry-webpack-bundle-size-optimizations-plugin",
132
- webpack: function webpack(compiler) {
133
- var _compiler$webpack2;
134
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
135
- // @ts-ignore webpack version compatibility shenanigans
136
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
137
- var DefinePlugin =
138
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
139
- // @ts-ignore webpack version compatibility shenanigans
140
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
141
- (compiler === null || compiler === void 0 ? void 0 : (_compiler$webpack2 = compiler.webpack) === null || _compiler$webpack2 === void 0 ? void 0 : _compiler$webpack2.DefinePlugin) || UnsafeDefinePlugin;
142
- compiler.options.plugins = compiler.options.plugins || [];
143
- compiler.options.plugins.push(
144
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
145
- new DefinePlugin(_objectSpread2({}, replacementValues)));
146
- }
147
- };
148
- };
149
- }
150
- function webpackDebugIdUploadPlugin(upload, logger, createDependencyOnBuildArtifacts, forceExitOnBuildCompletion) {
151
- var pluginName = "sentry-webpack-debug-id-upload-plugin";
152
- return {
153
- name: pluginName,
154
- webpack: function webpack(compiler) {
155
- var freeGlobalDependencyOnDebugIdSourcemapArtifacts = createDependencyOnBuildArtifacts();
156
- compiler.hooks.afterEmit.tapAsync(pluginName, function (compilation, callback) {
157
- var _ref;
158
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
159
- var outputPath = (_ref = compilation.outputOptions.path) !== null && _ref !== void 0 ? _ref : path__namespace.resolve();
160
- var buildArtifacts = Object.keys(compilation.assets).map(function (asset) {
161
- return path__namespace.join(outputPath, asset);
162
- });
163
- void upload(buildArtifacts).then(function () {
164
- callback();
165
- })["finally"](function () {
166
- freeGlobalDependencyOnDebugIdSourcemapArtifacts();
167
- });
168
- });
169
- if (forceExitOnBuildCompletion && compiler.options.mode === "production") {
170
- compiler.hooks.done.tap(pluginName, function () {
171
- setTimeout(function () {
172
- logger.debug("Exiting process after debug file upload");
173
- process.exit(0);
174
- });
175
- });
176
- }
177
- }
178
- };
179
- }
180
-
181
- // Detect webpack major version for telemetry (helps differentiate webpack 4 vs 5 usage)
182
- function getWebpackMajorVersion() {
183
- try {
184
- var _webpack$version, _webpack$default;
185
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
186
- // @ts-ignore - Rollup already transpiles this for us
187
- var req = node_module.createRequire((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || new URL('webpack4and5.js', document.baseURI).href)));
188
- var webpack = req("webpack");
189
- var version = (_webpack$version = webpack === null || webpack === void 0 ? void 0 : webpack.version) !== null && _webpack$version !== void 0 ? _webpack$version : webpack === null || webpack === void 0 ? void 0 : (_webpack$default = webpack["default"]) === null || _webpack$default === void 0 ? void 0 : _webpack$default.version;
190
- var webpackMajorVersion = version === null || version === void 0 ? void 0 : version.split(".")[0]; // "4" or "5"
191
- return webpackMajorVersion;
192
- } catch (error) {
193
- return undefined;
194
- }
195
- }
196
-
197
- /**
198
- * The factory function accepts BannerPlugin and DefinePlugin classes in
199
- * order to avoid direct dependencies on webpack.
200
- *
201
- * This allow us to export version of the plugin for webpack 5.1+ and compatible environments.
202
- *
203
- * Since webpack 5.1 compiler contains webpack module so plugins always use correct webpack version.
204
- */
205
- function sentryWebpackUnpluginFactory() {
206
- var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
207
- BannerPlugin = _ref2.BannerPlugin,
208
- DefinePlugin = _ref2.DefinePlugin;
209
- return bundlerPluginCore.sentryUnpluginFactory({
210
- injectionPlugin: webpackInjectionPlugin(BannerPlugin),
211
- componentNameAnnotatePlugin: webpackComponentNameAnnotatePlugin(),
212
- debugIdUploadPlugin: webpackDebugIdUploadPlugin,
213
- bundleSizeOptimizationsPlugin: webpackBundleSizeOptimizationsPlugin(DefinePlugin),
214
- getBundlerMajorVersion: getWebpackMajorVersion
215
- });
216
- }
217
-
218
- exports.sentryWebpackUnpluginFactory = sentryWebpackUnpluginFactory;
219
- //# sourceMappingURL=webpack4and5.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"webpack4and5.js","sources":["../../src/webpack4and5.ts"],"sourcesContent":["import {\n Options,\n sentryUnpluginFactory,\n stringToUUID,\n SentrySDKBuildFlags,\n createComponentNameAnnotateHooks,\n Logger,\n CodeInjection,\n getDebugIdSnippet,\n} from \"@sentry/bundler-plugin-core\";\nimport { createRequire } from \"node:module\";\nimport * as path from \"path\";\nimport { UnpluginOptions } from \"unplugin\";\nimport { v4 as uuidv4 } from \"uuid\";\n\n// since webpack 5.1 compiler contains webpack module so plugins always use correct webpack version\n// https://github.com/webpack/webpack/commit/65eca2e529ce1d79b79200d4bdb1ce1b81141459\n\ninterface BannerPluginCallbackArg {\n chunk?: {\n hash?: string;\n contentHash?: {\n javascript?: string;\n };\n };\n}\n\ntype UnsafeBannerPlugin = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (options: any): unknown;\n};\n\ntype UnsafeDefinePlugin = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (options: any): unknown;\n};\n\nfunction webpackInjectionPlugin(\n UnsafeBannerPlugin: UnsafeBannerPlugin | undefined\n): (injectionCode: CodeInjection, debugIds: boolean) => UnpluginOptions {\n return (injectionCode: CodeInjection, debugIds: boolean): UnpluginOptions => ({\n name: \"sentry-webpack-injection-plugin\",\n webpack(compiler) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore webpack version compatibility shenanigans\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n const BannerPlugin =\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore webpack version compatibility shenanigans\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n compiler?.webpack?.BannerPlugin || UnsafeBannerPlugin;\n\n compiler.options.plugins = compiler.options.plugins || [];\n compiler.options.plugins.push(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call\n new BannerPlugin({\n raw: true,\n include: /\\.(js|ts|jsx|tsx|mjs|cjs)(\\?[^?]*)?(#[^#]*)?$/,\n banner: (arg?: BannerPluginCallbackArg) => {\n const codeToInject = injectionCode.clone();\n if (debugIds) {\n const hash = arg?.chunk?.contentHash?.javascript ?? arg?.chunk?.hash;\n const debugId = hash ? stringToUUID(hash) : uuidv4();\n codeToInject.append(getDebugIdSnippet(debugId));\n }\n return codeToInject.code();\n },\n })\n );\n },\n });\n}\n\nfunction webpackComponentNameAnnotatePlugin(): (\n ignoredComponents: string[],\n injectIntoHtml: boolean\n) => UnpluginOptions {\n return (ignoredComponents: string[], injectIntoHtml: boolean) => ({\n name: \"sentry-webpack-component-name-annotate-plugin\",\n enforce: \"pre\",\n // Webpack needs this hook for loader logic, so the plugin is not run on unsupported file types\n transformInclude(id) {\n return id.endsWith(\".tsx\") || id.endsWith(\".jsx\");\n },\n transform: createComponentNameAnnotateHooks(ignoredComponents, injectIntoHtml).transform,\n });\n}\n\nfunction webpackBundleSizeOptimizationsPlugin(\n UnsafeDefinePlugin: UnsafeDefinePlugin | undefined\n): (replacementValues: SentrySDKBuildFlags) => UnpluginOptions {\n return (replacementValues: SentrySDKBuildFlags) => ({\n name: \"sentry-webpack-bundle-size-optimizations-plugin\",\n webpack(compiler) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore webpack version compatibility shenanigans\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n const DefinePlugin =\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore webpack version compatibility shenanigans\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n compiler?.webpack?.DefinePlugin || UnsafeDefinePlugin;\n\n compiler.options.plugins = compiler.options.plugins || [];\n compiler.options.plugins.push(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call\n new DefinePlugin({\n ...replacementValues,\n })\n );\n },\n });\n}\n\nfunction webpackDebugIdUploadPlugin(\n upload: (buildArtifacts: string[]) => Promise<void>,\n logger: Logger,\n createDependencyOnBuildArtifacts: () => () => void,\n forceExitOnBuildCompletion?: boolean\n): UnpluginOptions {\n const pluginName = \"sentry-webpack-debug-id-upload-plugin\";\n return {\n name: pluginName,\n webpack(compiler) {\n const freeGlobalDependencyOnDebugIdSourcemapArtifacts = createDependencyOnBuildArtifacts();\n\n compiler.hooks.afterEmit.tapAsync(pluginName, (compilation, callback: () => void) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const outputPath = (compilation.outputOptions.path as string | undefined) ?? path.resolve();\n const buildArtifacts = Object.keys(compilation.assets as Record<string, unknown>).map(\n (asset) => path.join(outputPath, asset)\n );\n void upload(buildArtifacts)\n .then(() => {\n callback();\n })\n .finally(() => {\n freeGlobalDependencyOnDebugIdSourcemapArtifacts();\n });\n });\n\n if (forceExitOnBuildCompletion && compiler.options.mode === \"production\") {\n compiler.hooks.done.tap(pluginName, () => {\n setTimeout(() => {\n logger.debug(\"Exiting process after debug file upload\");\n process.exit(0);\n });\n });\n }\n },\n };\n}\n\n// Detect webpack major version for telemetry (helps differentiate webpack 4 vs 5 usage)\nfunction getWebpackMajorVersion(): 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 webpack = req(\"webpack\") as { version?: string; default?: { version?: string } };\n const version = webpack?.version ?? webpack?.default?.version;\n const webpackMajorVersion = version?.split(\".\")[0]; // \"4\" or \"5\"\n return webpackMajorVersion;\n } catch (error) {\n return undefined;\n }\n}\n\n/**\n * The factory function accepts BannerPlugin and DefinePlugin classes in\n * order to avoid direct dependencies on webpack.\n *\n * This allow us to export version of the plugin for webpack 5.1+ and compatible environments.\n *\n * Since webpack 5.1 compiler contains webpack module so plugins always use correct webpack version.\n */\nexport function sentryWebpackUnpluginFactory({\n BannerPlugin,\n DefinePlugin,\n}: {\n BannerPlugin?: UnsafeBannerPlugin;\n DefinePlugin?: UnsafeDefinePlugin;\n} = {}): ReturnType<typeof sentryUnpluginFactory> {\n return sentryUnpluginFactory({\n injectionPlugin: webpackInjectionPlugin(BannerPlugin),\n componentNameAnnotatePlugin: webpackComponentNameAnnotatePlugin(),\n debugIdUploadPlugin: webpackDebugIdUploadPlugin,\n bundleSizeOptimizationsPlugin: webpackBundleSizeOptimizationsPlugin(DefinePlugin),\n getBundlerMajorVersion: getWebpackMajorVersion,\n });\n}\n\nexport type SentryWebpackPluginOptions = Options & {\n _experiments?: Options[\"_experiments\"] & {\n /**\n * If enabled, the webpack plugin will exit the build process after the build completes.\n * Use this with caution, as it will terminate the process.\n *\n * More information: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/345\n *\n * @default false\n */\n forceExitOnBuildCompletion?: boolean;\n };\n};\n"],"names":["webpackInjectionPlugin","UnsafeBannerPlugin","injectionCode","debugIds","name","webpack","compiler","_compiler$webpack","BannerPlugin","options","plugins","push","raw","include","banner","arg","codeToInject","clone","_arg$chunk$contentHas","_arg$chunk","_arg$chunk$contentHas2","_arg$chunk2","hash","chunk","contentHash","javascript","debugId","stringToUUID","uuidv4","append","getDebugIdSnippet","code","webpackComponentNameAnnotatePlugin","ignoredComponents","injectIntoHtml","enforce","transformInclude","id","endsWith","transform","createComponentNameAnnotateHooks","webpackBundleSizeOptimizationsPlugin","UnsafeDefinePlugin","replacementValues","_compiler$webpack2","DefinePlugin","_objectSpread","webpackDebugIdUploadPlugin","upload","logger","createDependencyOnBuildArtifacts","forceExitOnBuildCompletion","pluginName","freeGlobalDependencyOnDebugIdSourcemapArtifacts","hooks","afterEmit","tapAsync","compilation","callback","_ref","outputPath","outputOptions","path","resolve","buildArtifacts","Object","keys","assets","map","asset","join","then","mode","done","tap","setTimeout","debug","process","exit","getWebpackMajorVersion","_webpack$version","_webpack$default","req","createRequire","import","version","webpackMajorVersion","split","error","undefined","sentryWebpackUnpluginFactory","_ref2","arguments","length","sentryUnpluginFactory","injectionPlugin","componentNameAnnotatePlugin","debugIdUploadPlugin","bundleSizeOptimizationsPlugin","getBundlerMajorVersion"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA;AACA;AAqBA,SAASA,sBAAsBA,CAC7BC,kBAAkD,EACoB;EACtE,OAAO,UAACC,aAA4B,EAAEC,QAAiB,EAAA;IAAA,OAAuB;AAC5EC,MAAAA,IAAI,EAAE,iCAAiC;MACvCC,OAAO,EAAA,SAAAA,OAACC,CAAAA,QAAQ,E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AA4E,IAAAA,IAAAA,gBAAA,KAAhBA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,gBAAA,CAAkBI,OAAO,CAAA;AAC7D,IAAA,IAAMC,mBAAmB,GAAGD,OAAO,KAAPA,IAAAA,IAAAA,OAAO,uBAAPA,OAAO,CAAEE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACnD,IAAA,OAAOD,mBAAmB,CAAA;GAC3B,CAAC,OAAOE,KAAK,EAAE;AACd,IAAA,OAAOC,SAAS,CAAA;AAClB,GAAA;AACF,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,4BAA4BA,GAMM;AAAA,EAAA,IAAAC,KAAA,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAH,SAAA,GAAAG,SAAA,CAAA,CAAA,CAAA,GAA9C,EAAE;IALJpF,YAAY,GAAAmF,KAAA,CAAZnF,YAAY;IACZqC,YAAY,GAAA8C,KAAA,CAAZ9C,YAAY,CAAA;AAKZ,EAAA,OAAOiD,uCAAqB,CAAC;AAC3BC,IAAAA,eAAe,EAAE/F,sBAAsB,CAACQ,YAAY,CAAC;IACrDwF,2BAA2B,EAAEhE,kCAAkC,EAAE;AACjEiE,IAAAA,mBAAmB,EAAElD,0BAA0B;AAC/CmD,IAAAA,6BAA6B,EAAEzD,oCAAoC,CAACI,YAAY,CAAC;AACjFsD,IAAAA,sBAAsB,EAAEpB,sBAAAA;AAC1B,GAAC,CAAC,CAAA;AACJ;;;;"}
@@ -1,21 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var webpack4and5 = require('./webpack4and5.js');
6
- var bundlerPluginCore = require('@sentry/bundler-plugin-core');
7
- require('node:module');
8
- require('path');
9
- require('uuid');
10
-
11
- var sentryUnplugin = webpack4and5.sentryWebpackUnpluginFactory();
12
-
13
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
- var sentryWebpackPlugin = sentryUnplugin.webpack;
15
-
16
- Object.defineProperty(exports, 'sentryCliBinaryExists', {
17
- enumerable: true,
18
- get: function () { return bundlerPluginCore.sentryCliBinaryExists; }
19
- });
20
- exports.sentryWebpackPlugin = sentryWebpackPlugin;
21
- //# sourceMappingURL=webpack5.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"webpack5.js","sources":["../../src/webpack5.ts"],"sourcesContent":["import { SentryWebpackPluginOptions, sentryWebpackUnpluginFactory } from \"./webpack4and5\";\n\nconst sentryUnplugin = sentryWebpackUnpluginFactory();\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const sentryWebpackPlugin: (options?: SentryWebpackPluginOptions) => any =\n sentryUnplugin.webpack;\n\nexport { sentryCliBinaryExists } from \"@sentry/bundler-plugin-core\";\n\nexport type { SentryWebpackPluginOptions };\n"],"names":["sentryUnplugin","sentryWebpackUnpluginFactory","sentryWebpackPlugin","webpack"],"mappings":";;;;;;;;;;AAEA,IAAMA,cAAc,GAAGC,yCAA4B,EAAE,CAAA;;AAErD;AACaC,IAAAA,mBAAkE,GAC7EF,cAAc,CAACG;;;;;;;;"}
@@ -1,197 +0,0 @@
1
- import { sentryUnpluginFactory, stringToUUID, getDebugIdSnippet, createComponentNameAnnotateHooks } from '@sentry/bundler-plugin-core';
2
- import { createRequire } from 'node:module';
3
- import * as path from 'path';
4
- import { v4 } from 'uuid';
5
-
6
- function ownKeys(object, enumerableOnly) {
7
- var keys = Object.keys(object);
8
- if (Object.getOwnPropertySymbols) {
9
- var symbols = Object.getOwnPropertySymbols(object);
10
- enumerableOnly && (symbols = symbols.filter(function (sym) {
11
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
12
- })), keys.push.apply(keys, symbols);
13
- }
14
- return keys;
15
- }
16
- function _objectSpread2(target) {
17
- for (var i = 1; i < arguments.length; i++) {
18
- var source = null != arguments[i] ? arguments[i] : {};
19
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
20
- _defineProperty(target, key, source[key]);
21
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
22
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
23
- });
24
- }
25
- return target;
26
- }
27
- function _defineProperty(obj, key, value) {
28
- key = _toPropertyKey(key);
29
- if (key in obj) {
30
- Object.defineProperty(obj, key, {
31
- value: value,
32
- enumerable: true,
33
- configurable: true,
34
- writable: true
35
- });
36
- } else {
37
- obj[key] = value;
38
- }
39
- return obj;
40
- }
41
- function _toPrimitive(input, hint) {
42
- if (typeof input !== "object" || input === null) return input;
43
- var prim = input[Symbol.toPrimitive];
44
- if (prim !== undefined) {
45
- var res = prim.call(input, hint || "default");
46
- if (typeof res !== "object") return res;
47
- throw new TypeError("@@toPrimitive must return a primitive value.");
48
- }
49
- return (hint === "string" ? String : Number)(input);
50
- }
51
- function _toPropertyKey(arg) {
52
- var key = _toPrimitive(arg, "string");
53
- return typeof key === "symbol" ? key : String(key);
54
- }
55
-
56
- // since webpack 5.1 compiler contains webpack module so plugins always use correct webpack version
57
- // https://github.com/webpack/webpack/commit/65eca2e529ce1d79b79200d4bdb1ce1b81141459
58
- function webpackInjectionPlugin(UnsafeBannerPlugin) {
59
- return function (injectionCode, debugIds) {
60
- return {
61
- name: "sentry-webpack-injection-plugin",
62
- webpack: function webpack(compiler) {
63
- var _compiler$webpack;
64
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
65
- // @ts-ignore webpack version compatibility shenanigans
66
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
67
- var BannerPlugin =
68
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
69
- // @ts-ignore webpack version compatibility shenanigans
70
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
71
- (compiler === null || compiler === void 0 ? void 0 : (_compiler$webpack = compiler.webpack) === null || _compiler$webpack === void 0 ? void 0 : _compiler$webpack.BannerPlugin) || UnsafeBannerPlugin;
72
- compiler.options.plugins = compiler.options.plugins || [];
73
- compiler.options.plugins.push(
74
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
75
- new BannerPlugin({
76
- raw: true,
77
- include: /\.(js|ts|jsx|tsx|mjs|cjs)(\?[^?]*)?(#[^#]*)?$/,
78
- banner: function banner(arg) {
79
- var codeToInject = injectionCode.clone();
80
- if (debugIds) {
81
- var _arg$chunk$contentHas, _arg$chunk, _arg$chunk$contentHas2, _arg$chunk2;
82
- var hash = (_arg$chunk$contentHas = arg === null || arg === void 0 ? void 0 : (_arg$chunk = arg.chunk) === null || _arg$chunk === void 0 ? void 0 : (_arg$chunk$contentHas2 = _arg$chunk.contentHash) === null || _arg$chunk$contentHas2 === void 0 ? void 0 : _arg$chunk$contentHas2.javascript) !== null && _arg$chunk$contentHas !== void 0 ? _arg$chunk$contentHas : arg === null || arg === void 0 ? void 0 : (_arg$chunk2 = arg.chunk) === null || _arg$chunk2 === void 0 ? void 0 : _arg$chunk2.hash;
83
- var debugId = hash ? stringToUUID(hash) : v4();
84
- codeToInject.append(getDebugIdSnippet(debugId));
85
- }
86
- return codeToInject.code();
87
- }
88
- }));
89
- }
90
- };
91
- };
92
- }
93
- function webpackComponentNameAnnotatePlugin() {
94
- return function (ignoredComponents, injectIntoHtml) {
95
- return {
96
- name: "sentry-webpack-component-name-annotate-plugin",
97
- enforce: "pre",
98
- // Webpack needs this hook for loader logic, so the plugin is not run on unsupported file types
99
- transformInclude: function transformInclude(id) {
100
- return id.endsWith(".tsx") || id.endsWith(".jsx");
101
- },
102
- transform: createComponentNameAnnotateHooks(ignoredComponents, injectIntoHtml).transform
103
- };
104
- };
105
- }
106
- function webpackBundleSizeOptimizationsPlugin(UnsafeDefinePlugin) {
107
- return function (replacementValues) {
108
- return {
109
- name: "sentry-webpack-bundle-size-optimizations-plugin",
110
- webpack: function webpack(compiler) {
111
- var _compiler$webpack2;
112
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
113
- // @ts-ignore webpack version compatibility shenanigans
114
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
115
- var DefinePlugin =
116
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
117
- // @ts-ignore webpack version compatibility shenanigans
118
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
119
- (compiler === null || compiler === void 0 ? void 0 : (_compiler$webpack2 = compiler.webpack) === null || _compiler$webpack2 === void 0 ? void 0 : _compiler$webpack2.DefinePlugin) || UnsafeDefinePlugin;
120
- compiler.options.plugins = compiler.options.plugins || [];
121
- compiler.options.plugins.push(
122
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
123
- new DefinePlugin(_objectSpread2({}, replacementValues)));
124
- }
125
- };
126
- };
127
- }
128
- function webpackDebugIdUploadPlugin(upload, logger, createDependencyOnBuildArtifacts, forceExitOnBuildCompletion) {
129
- var pluginName = "sentry-webpack-debug-id-upload-plugin";
130
- return {
131
- name: pluginName,
132
- webpack: function webpack(compiler) {
133
- var freeGlobalDependencyOnDebugIdSourcemapArtifacts = createDependencyOnBuildArtifacts();
134
- compiler.hooks.afterEmit.tapAsync(pluginName, function (compilation, callback) {
135
- var _ref;
136
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
137
- var outputPath = (_ref = compilation.outputOptions.path) !== null && _ref !== void 0 ? _ref : path.resolve();
138
- var buildArtifacts = Object.keys(compilation.assets).map(function (asset) {
139
- return path.join(outputPath, asset);
140
- });
141
- void upload(buildArtifacts).then(function () {
142
- callback();
143
- })["finally"](function () {
144
- freeGlobalDependencyOnDebugIdSourcemapArtifacts();
145
- });
146
- });
147
- if (forceExitOnBuildCompletion && compiler.options.mode === "production") {
148
- compiler.hooks.done.tap(pluginName, function () {
149
- setTimeout(function () {
150
- logger.debug("Exiting process after debug file upload");
151
- process.exit(0);
152
- });
153
- });
154
- }
155
- }
156
- };
157
- }
158
-
159
- // Detect webpack major version for telemetry (helps differentiate webpack 4 vs 5 usage)
160
- function getWebpackMajorVersion() {
161
- try {
162
- var _webpack$version, _webpack$default;
163
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
164
- // @ts-ignore - Rollup already transpiles this for us
165
- var req = createRequire(import.meta.url);
166
- var webpack = req("webpack");
167
- var version = (_webpack$version = webpack === null || webpack === void 0 ? void 0 : webpack.version) !== null && _webpack$version !== void 0 ? _webpack$version : webpack === null || webpack === void 0 ? void 0 : (_webpack$default = webpack["default"]) === null || _webpack$default === void 0 ? void 0 : _webpack$default.version;
168
- var webpackMajorVersion = version === null || version === void 0 ? void 0 : version.split(".")[0]; // "4" or "5"
169
- return webpackMajorVersion;
170
- } catch (error) {
171
- return undefined;
172
- }
173
- }
174
-
175
- /**
176
- * The factory function accepts BannerPlugin and DefinePlugin classes in
177
- * order to avoid direct dependencies on webpack.
178
- *
179
- * This allow us to export version of the plugin for webpack 5.1+ and compatible environments.
180
- *
181
- * Since webpack 5.1 compiler contains webpack module so plugins always use correct webpack version.
182
- */
183
- function sentryWebpackUnpluginFactory() {
184
- var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
185
- BannerPlugin = _ref2.BannerPlugin,
186
- DefinePlugin = _ref2.DefinePlugin;
187
- return sentryUnpluginFactory({
188
- injectionPlugin: webpackInjectionPlugin(BannerPlugin),
189
- componentNameAnnotatePlugin: webpackComponentNameAnnotatePlugin(),
190
- debugIdUploadPlugin: webpackDebugIdUploadPlugin,
191
- bundleSizeOptimizationsPlugin: webpackBundleSizeOptimizationsPlugin(DefinePlugin),
192
- getBundlerMajorVersion: getWebpackMajorVersion
193
- });
194
- }
195
-
196
- export { sentryWebpackUnpluginFactory as s };
197
- //# sourceMappingURL=webpack4and5.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"webpack4and5.mjs","sources":["../../src/webpack4and5.ts"],"sourcesContent":["import {\n Options,\n sentryUnpluginFactory,\n stringToUUID,\n SentrySDKBuildFlags,\n createComponentNameAnnotateHooks,\n Logger,\n CodeInjection,\n getDebugIdSnippet,\n} from \"@sentry/bundler-plugin-core\";\nimport { createRequire } from \"node:module\";\nimport * as path from \"path\";\nimport { UnpluginOptions } from \"unplugin\";\nimport { v4 as uuidv4 } from \"uuid\";\n\n// since webpack 5.1 compiler contains webpack module so plugins always use correct webpack version\n// https://github.com/webpack/webpack/commit/65eca2e529ce1d79b79200d4bdb1ce1b81141459\n\ninterface BannerPluginCallbackArg {\n chunk?: {\n hash?: string;\n contentHash?: {\n javascript?: string;\n };\n };\n}\n\ntype UnsafeBannerPlugin = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (options: any): unknown;\n};\n\ntype UnsafeDefinePlugin = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (options: any): unknown;\n};\n\nfunction webpackInjectionPlugin(\n UnsafeBannerPlugin: UnsafeBannerPlugin | undefined\n): (injectionCode: CodeInjection, debugIds: boolean) => UnpluginOptions {\n return (injectionCode: CodeInjection, debugIds: boolean): UnpluginOptions => ({\n name: \"sentry-webpack-injection-plugin\",\n webpack(compiler) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore webpack version compatibility shenanigans\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n const BannerPlugin =\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore webpack version compatibility shenanigans\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n compiler?.webpack?.BannerPlugin || UnsafeBannerPlugin;\n\n compiler.options.plugins = compiler.options.plugins || [];\n compiler.options.plugins.push(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call\n new BannerPlugin({\n raw: true,\n include: /\\.(js|ts|jsx|tsx|mjs|cjs)(\\?[^?]*)?(#[^#]*)?$/,\n banner: (arg?: BannerPluginCallbackArg) => {\n const codeToInject = injectionCode.clone();\n if (debugIds) {\n const hash = arg?.chunk?.contentHash?.javascript ?? arg?.chunk?.hash;\n const debugId = hash ? stringToUUID(hash) : uuidv4();\n codeToInject.append(getDebugIdSnippet(debugId));\n }\n return codeToInject.code();\n },\n })\n );\n },\n });\n}\n\nfunction webpackComponentNameAnnotatePlugin(): (\n ignoredComponents: string[],\n injectIntoHtml: boolean\n) => UnpluginOptions {\n return (ignoredComponents: string[], injectIntoHtml: boolean) => ({\n name: \"sentry-webpack-component-name-annotate-plugin\",\n enforce: \"pre\",\n // Webpack needs this hook for loader logic, so the plugin is not run on unsupported file types\n transformInclude(id) {\n return id.endsWith(\".tsx\") || id.endsWith(\".jsx\");\n },\n transform: createComponentNameAnnotateHooks(ignoredComponents, injectIntoHtml).transform,\n });\n}\n\nfunction webpackBundleSizeOptimizationsPlugin(\n UnsafeDefinePlugin: UnsafeDefinePlugin | undefined\n): (replacementValues: SentrySDKBuildFlags) => UnpluginOptions {\n return (replacementValues: SentrySDKBuildFlags) => ({\n name: \"sentry-webpack-bundle-size-optimizations-plugin\",\n webpack(compiler) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore webpack version compatibility shenanigans\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n const DefinePlugin =\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore webpack version compatibility shenanigans\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n compiler?.webpack?.DefinePlugin || UnsafeDefinePlugin;\n\n compiler.options.plugins = compiler.options.plugins || [];\n compiler.options.plugins.push(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call\n new DefinePlugin({\n ...replacementValues,\n })\n );\n },\n });\n}\n\nfunction webpackDebugIdUploadPlugin(\n upload: (buildArtifacts: string[]) => Promise<void>,\n logger: Logger,\n createDependencyOnBuildArtifacts: () => () => void,\n forceExitOnBuildCompletion?: boolean\n): UnpluginOptions {\n const pluginName = \"sentry-webpack-debug-id-upload-plugin\";\n return {\n name: pluginName,\n webpack(compiler) {\n const freeGlobalDependencyOnDebugIdSourcemapArtifacts = createDependencyOnBuildArtifacts();\n\n compiler.hooks.afterEmit.tapAsync(pluginName, (compilation, callback: () => void) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const outputPath = (compilation.outputOptions.path as string | undefined) ?? path.resolve();\n const buildArtifacts = Object.keys(compilation.assets as Record<string, unknown>).map(\n (asset) => path.join(outputPath, asset)\n );\n void upload(buildArtifacts)\n .then(() => {\n callback();\n })\n .finally(() => {\n freeGlobalDependencyOnDebugIdSourcemapArtifacts();\n });\n });\n\n if (forceExitOnBuildCompletion && compiler.options.mode === \"production\") {\n compiler.hooks.done.tap(pluginName, () => {\n setTimeout(() => {\n logger.debug(\"Exiting process after debug file upload\");\n process.exit(0);\n });\n });\n }\n },\n };\n}\n\n// Detect webpack major version for telemetry (helps differentiate webpack 4 vs 5 usage)\nfunction getWebpackMajorVersion(): 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 webpack = req(\"webpack\") as { version?: string; default?: { version?: string } };\n const version = webpack?.version ?? webpack?.default?.version;\n const webpackMajorVersion = version?.split(\".\")[0]; // \"4\" or \"5\"\n return webpackMajorVersion;\n } catch (error) {\n return undefined;\n }\n}\n\n/**\n * The factory function accepts BannerPlugin and DefinePlugin classes in\n * order to avoid direct dependencies on webpack.\n *\n * This allow us to export version of the plugin for webpack 5.1+ and compatible environments.\n *\n * Since webpack 5.1 compiler contains webpack module so plugins always use correct webpack version.\n */\nexport function sentryWebpackUnpluginFactory({\n BannerPlugin,\n DefinePlugin,\n}: {\n BannerPlugin?: UnsafeBannerPlugin;\n DefinePlugin?: UnsafeDefinePlugin;\n} = {}): ReturnType<typeof sentryUnpluginFactory> {\n return sentryUnpluginFactory({\n injectionPlugin: webpackInjectionPlugin(BannerPlugin),\n componentNameAnnotatePlugin: webpackComponentNameAnnotatePlugin(),\n debugIdUploadPlugin: webpackDebugIdUploadPlugin,\n bundleSizeOptimizationsPlugin: webpackBundleSizeOptimizationsPlugin(DefinePlugin),\n getBundlerMajorVersion: getWebpackMajorVersion,\n });\n}\n\nexport type SentryWebpackPluginOptions = Options & {\n _experiments?: Options[\"_experiments\"] & {\n /**\n * If enabled, the webpack plugin will exit the build process after the build completes.\n * Use this with caution, as it will terminate the process.\n *\n * More information: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/345\n *\n * @default false\n */\n forceExitOnBuildCompletion?: boolean;\n };\n};\n"],"names":["webpackInjectionPlugin","UnsafeBannerPlugin","injectionCode","debugIds","name","webpack","compiler","_compiler$webpack","BannerPlugin","options","plugins","push","raw","include","banner","arg","codeToInject","clone","_arg$chunk$contentHas","_arg$chunk","_arg$chunk$contentHas2","_arg$chunk2","hash","chunk","contentHash","javascript","debugId","stringToUUID","uuidv4","append","getDebugIdSnippet","code","webpackComponentNameAnnotatePlugin","ignoredComponents","injectIntoHtml","enforce","transformInclude","id","endsWith","transform","createComponentNameAnnotateHooks","webpackBundleSizeOptimizationsPlugin","UnsafeDefinePlugin","replacementValues","_compiler$webpack2","DefinePlugin","_objectSpread","webpackDebugIdUploadPlugin","upload","logger","createDependencyOnBuildArtifacts","forceExitOnBuildCompletion","pluginName","freeGlobalDependencyOnDebugIdSourcemapArtifacts","hooks","afterEmit","tapAsync","compilation","callback","_ref","outputPath","outputOptions","path","resolve","buildArtifacts","Object","keys","assets","map","asset","join","then","mode","done","tap","setTimeout","debug","process","exit","getWebpackMajorVersion","_webpack$version","_webpack$default","req","createRequire","import","meta","url","version","webpackMajorVersion","split","error","undefined","sentryWebpackUnpluginFactory","_ref2","arguments","length","sentryUnpluginFactory","injectionPlugin","componentNameAnnotatePlugin","debugIdUploadPlugin","bundleSizeOptimizationsPl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AAA,sBAAsB,EAAEtB,sBAAAA;AAC1B,GAAC,CAAC,CAAA;AACJ;;;;"}
@@ -1,13 +0,0 @@
1
- import { s as sentryWebpackUnpluginFactory } from './webpack4and5.mjs';
2
- export { sentryCliBinaryExists } from '@sentry/bundler-plugin-core';
3
- import 'node:module';
4
- import 'path';
5
- import 'uuid';
6
-
7
- var sentryUnplugin = sentryWebpackUnpluginFactory();
8
-
9
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
- var sentryWebpackPlugin = sentryUnplugin.webpack;
11
-
12
- export { sentryWebpackPlugin };
13
- //# sourceMappingURL=webpack5.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"webpack5.mjs","sources":["../../src/webpack5.ts"],"sourcesContent":["import { SentryWebpackPluginOptions, sentryWebpackUnpluginFactory } from \"./webpack4and5\";\n\nconst sentryUnplugin = sentryWebpackUnpluginFactory();\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const sentryWebpackPlugin: (options?: SentryWebpackPluginOptions) => any =\n sentryUnplugin.webpack;\n\nexport { sentryCliBinaryExists } from \"@sentry/bundler-plugin-core\";\n\nexport type { SentryWebpackPluginOptions };\n"],"names":["sentryUnplugin","sentryWebpackUnpluginFactory","sentryWebpackPlugin","webpack"],"mappings":";;;;;;AAEA,IAAMA,cAAc,GAAGC,4BAA4B,EAAE,CAAA;;AAErD;AACaC,IAAAA,mBAAkE,GAC7EF,cAAc,CAACG;;;;"}