@sentry/webpack-plugin 5.1.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/cjs/component-annotation-transform.js +5 -3
- package/dist/cjs/component-annotation-transform.js.map +1 -1
- package/dist/cjs/index.js +10 -146
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/webpack4and5.js +145 -0
- package/dist/cjs/webpack4and5.js.map +1 -0
- package/dist/cjs/webpack5.js +14 -0
- package/dist/cjs/webpack5.js.map +1 -0
- package/dist/esm/component-annotation-transform.mjs +1 -1
- package/dist/esm/index.mjs +5 -116
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/webpack4and5.mjs +111 -0
- package/dist/esm/webpack4and5.mjs.map +1 -0
- package/dist/esm/webpack5.mjs +7 -0
- package/dist/esm/webpack5.mjs.map +1 -0
- package/package.json +10 -15
package/README.md
CHANGED
|
@@ -248,10 +248,12 @@ Default: `[]`
|
|
|
248
248
|
|
|
249
249
|
### `sourcemaps.rewriteSources`
|
|
250
250
|
|
|
251
|
-
Type: `(source: string, map: any) => string`
|
|
251
|
+
Type: `(source: string, map: any, context?: { mapDir: string }) => string`
|
|
252
252
|
|
|
253
253
|
Hook to rewrite the `sources` field inside the source map before being uploaded to Sentry. Does not modify the actual source map. Effectively, this modifies how files inside the stacktrace will show up in Sentry.
|
|
254
254
|
|
|
255
|
+
The `context.mapDir` parameter provides the directory path of the source map file, which is useful for resolving relative source paths (e.g. `path.resolve(context.mapDir, source)`).
|
|
256
|
+
|
|
255
257
|
Defaults to making all sources relative to `process.cwd()` while building.
|
|
256
258
|
|
|
257
259
|
### `sourcemaps.resolveSourceMap`
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
3
5
|
//#region src/component-annotation-transform.ts
|
|
4
6
|
async function transform(source, map) {
|
|
5
7
|
const callback = this.async();
|
|
@@ -16,7 +18,7 @@ async function transform(source, map) {
|
|
|
16
18
|
else callback(new Error(String(error)));
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
|
-
|
|
20
21
|
//#endregion
|
|
21
22
|
exports.default = transform;
|
|
23
|
+
|
|
22
24
|
//# sourceMappingURL=component-annotation-transform.js.map
|
|
@@ -1 +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":"
|
|
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,158 +1,22 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
2
|
-
|
|
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));
|
|
27
|
-
|
|
28
|
-
//#endregion
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_webpack4and5 = require("./webpack4and5.js");
|
|
29
3
|
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
4
|
let webpack = require("webpack");
|
|
36
|
-
webpack = __toESM(webpack);
|
|
37
|
-
|
|
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
|
-
};
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
//#endregion
|
|
5
|
+
webpack = require_webpack4and5.__toESM(webpack);
|
|
142
6
|
//#region src/index.ts
|
|
143
7
|
const BannerPlugin = webpack?.BannerPlugin || webpack?.default?.BannerPlugin;
|
|
144
8
|
const DefinePlugin = webpack?.DefinePlugin || webpack?.default?.DefinePlugin;
|
|
145
|
-
const sentryWebpackPlugin = sentryWebpackPluginFactory({
|
|
9
|
+
const sentryWebpackPlugin = require_webpack4and5.sentryWebpackPluginFactory({
|
|
146
10
|
BannerPlugin,
|
|
147
11
|
DefinePlugin
|
|
148
12
|
});
|
|
149
|
-
|
|
150
13
|
//#endregion
|
|
151
|
-
Object.defineProperty(exports,
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
14
|
+
Object.defineProperty(exports, "sentryCliBinaryExists", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function() {
|
|
17
|
+
return _sentry_bundler_plugin_core.sentryCliBinaryExists;
|
|
18
|
+
}
|
|
156
19
|
});
|
|
157
20
|
exports.sentryWebpackPlugin = sentryWebpackPlugin;
|
|
21
|
+
|
|
158
22
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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":"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"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["webpack4or5","sentryWebpackPluginFactory"],"sources":["../../src/index.ts"],"sourcesContent":["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":";;;;;;AAGA,MAAM,eAAeA,SAAa,gBAAgBA,SAAa,SAAS;AAExE,MAAM,eAAeA,SAAa,gBAAgBA,SAAa,SAAS;AAGxE,MAAa,sBACXC,qBAAAA,2BAA2B;CACzB;CACA;CACD,CAAC"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
//#endregion
|
|
23
|
+
let _sentry_bundler_plugin_core = require("@sentry/bundler-plugin-core");
|
|
24
|
+
let node_path = require("node:path");
|
|
25
|
+
node_path = __toESM(node_path);
|
|
26
|
+
let node_url = require("node:url");
|
|
27
|
+
let node_module = require("node:module");
|
|
28
|
+
let node_crypto = require("node:crypto");
|
|
29
|
+
//#region src/webpack4and5.ts
|
|
30
|
+
const dirname = node_path.dirname((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
31
|
+
const COMPONENT_ANNOTATION_LOADER = node_path.resolve(dirname, typeof __dirname !== "undefined" ? "component-annotation-transform.js" : "component-annotation-transform.mjs");
|
|
32
|
+
function getWebpackMajorVersion() {
|
|
33
|
+
try {
|
|
34
|
+
const webpack = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("webpack");
|
|
35
|
+
return (webpack?.version ?? webpack?.default?.version)?.split(".")[0];
|
|
36
|
+
} catch (error) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The factory function accepts BannerPlugin and DefinePlugin classes in
|
|
42
|
+
* order to avoid direct dependencies on webpack.
|
|
43
|
+
*
|
|
44
|
+
* This allow us to export version of the plugin for webpack 5.1+ and compatible environments.
|
|
45
|
+
*
|
|
46
|
+
* Since webpack 5.1 compiler contains webpack module so plugins always use correct webpack version.
|
|
47
|
+
*/
|
|
48
|
+
function sentryWebpackPluginFactory({ BannerPlugin: UnsafeBannerPlugin, DefinePlugin: UnsafeDefinePlugin } = {}) {
|
|
49
|
+
return function sentryWebpackPlugin(userOptions = {}) {
|
|
50
|
+
const sentryBuildPluginManager = (0, _sentry_bundler_plugin_core.createSentryBuildPluginManager)(userOptions, {
|
|
51
|
+
loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? "[sentry-webpack-plugin]",
|
|
52
|
+
buildTool: "webpack",
|
|
53
|
+
buildToolMajorVersion: getWebpackMajorVersion()
|
|
54
|
+
});
|
|
55
|
+
const { logger, normalizedOptions: options, bundleSizeOptimizationReplacementValues: replacementValues, bundleMetadata, createDependencyOnBuildArtifacts } = sentryBuildPluginManager;
|
|
56
|
+
if (options.disable) return { apply() {} };
|
|
57
|
+
if (process.cwd().match(/\\node_modules\\|\/node_modules\//)) logger.warn("Running Sentry plugin from within a `node_modules` folder. Some features may not work.");
|
|
58
|
+
const sourcemapsEnabled = options.sourcemaps?.disable !== true;
|
|
59
|
+
const staticInjectionCode = new _sentry_bundler_plugin_core.CodeInjection();
|
|
60
|
+
if (!options.release.inject) logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
|
|
61
|
+
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.");
|
|
62
|
+
else staticInjectionCode.append((0, _sentry_bundler_plugin_core.generateReleaseInjectorCode)({
|
|
63
|
+
release: options.release.name,
|
|
64
|
+
injectBuildInformation: options._experiments.injectBuildInformation || false
|
|
65
|
+
}));
|
|
66
|
+
if (Object.keys(bundleMetadata).length > 0) staticInjectionCode.append((0, _sentry_bundler_plugin_core.generateModuleMetadataInjectorCode)(bundleMetadata));
|
|
67
|
+
const transformAnnotations = options.reactComponentAnnotation?.enabled ? (0, _sentry_bundler_plugin_core.createComponentNameAnnotateHooks)(options.reactComponentAnnotation?.ignoredComponents || [], !!options.reactComponentAnnotation?._experimentalInjectIntoHtml) : void 0;
|
|
68
|
+
const transformReplace = Object.keys(replacementValues).length > 0;
|
|
69
|
+
return { apply(compiler) {
|
|
70
|
+
sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {});
|
|
71
|
+
const BannerPlugin = compiler?.webpack?.BannerPlugin || UnsafeBannerPlugin;
|
|
72
|
+
const DefinePlugin = compiler?.webpack?.DefinePlugin || UnsafeDefinePlugin;
|
|
73
|
+
if (!staticInjectionCode.isEmpty() || sourcemapsEnabled) if (!BannerPlugin) logger.warn("BannerPlugin is not available. Skipping code injection. This usually means webpack is not properly configured.");
|
|
74
|
+
else {
|
|
75
|
+
compiler.options.plugins = compiler.options.plugins || [];
|
|
76
|
+
compiler.options.plugins.push(new BannerPlugin({
|
|
77
|
+
raw: true,
|
|
78
|
+
include: /\.(js|ts|jsx|tsx|mjs|cjs)(\?[^?]*)?(#[^#]*)?$/,
|
|
79
|
+
banner: (arg) => {
|
|
80
|
+
const codeToInject = staticInjectionCode.clone();
|
|
81
|
+
if (sourcemapsEnabled) {
|
|
82
|
+
const hash = arg?.chunk?.contentHash?.javascript ?? arg?.chunk?.hash;
|
|
83
|
+
const debugId = hash ? (0, _sentry_bundler_plugin_core.stringToUUID)(hash) : (0, node_crypto.randomUUID)();
|
|
84
|
+
codeToInject.append((0, _sentry_bundler_plugin_core.getDebugIdSnippet)(debugId));
|
|
85
|
+
}
|
|
86
|
+
return codeToInject.code();
|
|
87
|
+
}
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
if (transformReplace && DefinePlugin) {
|
|
91
|
+
compiler.options.plugins = compiler.options.plugins || [];
|
|
92
|
+
compiler.options.plugins.push(new DefinePlugin(replacementValues));
|
|
93
|
+
}
|
|
94
|
+
if (transformAnnotations?.transform) {
|
|
95
|
+
compiler.options.module = compiler.options.module || {};
|
|
96
|
+
compiler.options.module.rules = compiler.options.module.rules || [];
|
|
97
|
+
compiler.options.module.rules.unshift({
|
|
98
|
+
test: /\.[jt]sx$/,
|
|
99
|
+
exclude: /node_modules/,
|
|
100
|
+
enforce: "pre",
|
|
101
|
+
use: [{
|
|
102
|
+
loader: COMPONENT_ANNOTATION_LOADER,
|
|
103
|
+
options: { transform: transformAnnotations.transform }
|
|
104
|
+
}]
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
compiler.hooks.afterEmit.tapAsync("sentry-webpack-plugin", (compilation, callback) => {
|
|
108
|
+
const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
|
|
109
|
+
const upload = (0, _sentry_bundler_plugin_core.createDebugIdUploadFunction)({ sentryBuildPluginManager });
|
|
110
|
+
sentryBuildPluginManager.createRelease().then(async () => {
|
|
111
|
+
if (sourcemapsEnabled && options.sourcemaps?.disable !== "disable-upload") {
|
|
112
|
+
const outputPath = compilation.outputOptions.path ?? node_path.resolve();
|
|
113
|
+
await upload(Object.keys(compilation.assets).map((asset) => node_path.join(outputPath, asset)));
|
|
114
|
+
}
|
|
115
|
+
}).then(() => {
|
|
116
|
+
callback();
|
|
117
|
+
}).finally(() => {
|
|
118
|
+
freeGlobalDependencyOnBuildArtifacts();
|
|
119
|
+
sentryBuildPluginManager.deleteArtifacts();
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
if (userOptions._experiments?.forceExitOnBuildCompletion && compiler.options.mode === "production") compiler.hooks.done.tap("sentry-webpack-plugin", () => {
|
|
123
|
+
setTimeout(() => {
|
|
124
|
+
logger.debug("Exiting process after debug file upload");
|
|
125
|
+
process.exit(0);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
} };
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
Object.defineProperty(exports, "__toESM", {
|
|
133
|
+
enumerable: true,
|
|
134
|
+
get: function() {
|
|
135
|
+
return __toESM;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
Object.defineProperty(exports, "sentryWebpackPluginFactory", {
|
|
139
|
+
enumerable: true,
|
|
140
|
+
get: function() {
|
|
141
|
+
return sentryWebpackPluginFactory;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
//# sourceMappingURL=webpack4and5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webpack4and5.js","names":["path","CodeInjection"],"sources":["../../src/webpack4and5.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 { randomUUID } from \"node:crypto\";\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) : randomUUID();\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"],"mappings":"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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_webpack4and5 = require("./webpack4and5.js");
|
|
3
|
+
let _sentry_bundler_plugin_core = require("@sentry/bundler-plugin-core");
|
|
4
|
+
const sentryWebpackPlugin = require_webpack4and5.sentryWebpackPluginFactory();
|
|
5
|
+
//#endregion
|
|
6
|
+
Object.defineProperty(exports, "sentryCliBinaryExists", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return _sentry_bundler_plugin_core.sentryCliBinaryExists;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.sentryWebpackPlugin = sentryWebpackPlugin;
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=webpack5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webpack5.js","names":["sentryWebpackPluginFactory"],"sources":["../../src/webpack5.ts"],"sourcesContent":["import { SentryWebpackPluginOptions, sentryWebpackPluginFactory } from \"./webpack4and5\";\n\nconst createSentryWebpackPlugin = sentryWebpackPluginFactory();\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const sentryWebpackPlugin: (options?: SentryWebpackPluginOptions) => any =\n createSentryWebpackPlugin;\n\nexport { sentryCliBinaryExists } from \"@sentry/bundler-plugin-core\";\n\nexport type { SentryWebpackPluginOptions };\n"],"mappings":";;;AAKA,MAAa,sBAHqBA,qBAAAA,4BAA4B"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,122 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import * as path from "node:path";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
-
import { v4 } from "uuid";
|
|
1
|
+
import { t as sentryWebpackPluginFactory } from "./webpack4and5.mjs";
|
|
2
|
+
import { sentryCliBinaryExists } from "@sentry/bundler-plugin-core";
|
|
6
3
|
import * as webpack4or5 from "webpack";
|
|
7
|
-
|
|
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
|
-
}
|
|
110
|
-
|
|
111
|
-
//#endregion
|
|
112
|
-
//#region src/index.ts
|
|
113
|
-
const BannerPlugin = webpack4or5?.BannerPlugin || webpack4or5?.default?.BannerPlugin;
|
|
114
|
-
const DefinePlugin = webpack4or5?.DefinePlugin || webpack4or5?.default?.DefinePlugin;
|
|
115
4
|
const sentryWebpackPlugin = sentryWebpackPluginFactory({
|
|
116
|
-
BannerPlugin,
|
|
117
|
-
DefinePlugin
|
|
5
|
+
BannerPlugin: webpack4or5?.BannerPlugin || webpack4or5?.default?.BannerPlugin,
|
|
6
|
+
DefinePlugin: webpack4or5?.DefinePlugin || webpack4or5?.default?.DefinePlugin
|
|
118
7
|
});
|
|
119
|
-
|
|
120
8
|
//#endregion
|
|
121
9
|
export { sentryCliBinaryExists, sentryWebpackPlugin };
|
|
10
|
+
|
|
122
11
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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":"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"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/index.ts"],"sourcesContent":["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":";;;AAQA,MAAa,sBACX,2BAA2B;CACzB,cAPiB,aAAa,gBAAgB,aAAa,SAAS;CAQpE,cANiB,aAAa,gBAAgB,aAAa,SAAS;CAOrE,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { CodeInjection, createComponentNameAnnotateHooks, createDebugIdUploadFunction, createSentryBuildPluginManager, generateModuleMetadataInjectorCode, generateReleaseInjectorCode, getDebugIdSnippet, stringToUUID } from "@sentry/bundler-plugin-core";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { randomUUID } from "node:crypto";
|
|
6
|
+
//#region src/webpack4and5.ts
|
|
7
|
+
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const COMPONENT_ANNOTATION_LOADER = path.resolve(dirname, typeof __dirname !== "undefined" ? "component-annotation-transform.js" : "component-annotation-transform.mjs");
|
|
9
|
+
function getWebpackMajorVersion() {
|
|
10
|
+
try {
|
|
11
|
+
const webpack = createRequire(import.meta.url)("webpack");
|
|
12
|
+
return (webpack?.version ?? webpack?.default?.version)?.split(".")[0];
|
|
13
|
+
} catch (error) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The factory function accepts BannerPlugin and DefinePlugin classes in
|
|
19
|
+
* order to avoid direct dependencies on webpack.
|
|
20
|
+
*
|
|
21
|
+
* This allow us to export version of the plugin for webpack 5.1+ and compatible environments.
|
|
22
|
+
*
|
|
23
|
+
* Since webpack 5.1 compiler contains webpack module so plugins always use correct webpack version.
|
|
24
|
+
*/
|
|
25
|
+
function sentryWebpackPluginFactory({ BannerPlugin: UnsafeBannerPlugin, DefinePlugin: UnsafeDefinePlugin } = {}) {
|
|
26
|
+
return function sentryWebpackPlugin(userOptions = {}) {
|
|
27
|
+
const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {
|
|
28
|
+
loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? "[sentry-webpack-plugin]",
|
|
29
|
+
buildTool: "webpack",
|
|
30
|
+
buildToolMajorVersion: getWebpackMajorVersion()
|
|
31
|
+
});
|
|
32
|
+
const { logger, normalizedOptions: options, bundleSizeOptimizationReplacementValues: replacementValues, bundleMetadata, createDependencyOnBuildArtifacts } = sentryBuildPluginManager;
|
|
33
|
+
if (options.disable) return { apply() {} };
|
|
34
|
+
if (process.cwd().match(/\\node_modules\\|\/node_modules\//)) logger.warn("Running Sentry plugin from within a `node_modules` folder. Some features may not work.");
|
|
35
|
+
const sourcemapsEnabled = options.sourcemaps?.disable !== true;
|
|
36
|
+
const staticInjectionCode = new CodeInjection();
|
|
37
|
+
if (!options.release.inject) logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
|
|
38
|
+
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.");
|
|
39
|
+
else staticInjectionCode.append(generateReleaseInjectorCode({
|
|
40
|
+
release: options.release.name,
|
|
41
|
+
injectBuildInformation: options._experiments.injectBuildInformation || false
|
|
42
|
+
}));
|
|
43
|
+
if (Object.keys(bundleMetadata).length > 0) staticInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));
|
|
44
|
+
const transformAnnotations = options.reactComponentAnnotation?.enabled ? createComponentNameAnnotateHooks(options.reactComponentAnnotation?.ignoredComponents || [], !!options.reactComponentAnnotation?._experimentalInjectIntoHtml) : void 0;
|
|
45
|
+
const transformReplace = Object.keys(replacementValues).length > 0;
|
|
46
|
+
return { apply(compiler) {
|
|
47
|
+
sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {});
|
|
48
|
+
const BannerPlugin = compiler?.webpack?.BannerPlugin || UnsafeBannerPlugin;
|
|
49
|
+
const DefinePlugin = compiler?.webpack?.DefinePlugin || UnsafeDefinePlugin;
|
|
50
|
+
if (!staticInjectionCode.isEmpty() || sourcemapsEnabled) if (!BannerPlugin) logger.warn("BannerPlugin is not available. Skipping code injection. This usually means webpack is not properly configured.");
|
|
51
|
+
else {
|
|
52
|
+
compiler.options.plugins = compiler.options.plugins || [];
|
|
53
|
+
compiler.options.plugins.push(new BannerPlugin({
|
|
54
|
+
raw: true,
|
|
55
|
+
include: /\.(js|ts|jsx|tsx|mjs|cjs)(\?[^?]*)?(#[^#]*)?$/,
|
|
56
|
+
banner: (arg) => {
|
|
57
|
+
const codeToInject = staticInjectionCode.clone();
|
|
58
|
+
if (sourcemapsEnabled) {
|
|
59
|
+
const hash = arg?.chunk?.contentHash?.javascript ?? arg?.chunk?.hash;
|
|
60
|
+
const debugId = hash ? stringToUUID(hash) : randomUUID();
|
|
61
|
+
codeToInject.append(getDebugIdSnippet(debugId));
|
|
62
|
+
}
|
|
63
|
+
return codeToInject.code();
|
|
64
|
+
}
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
if (transformReplace && DefinePlugin) {
|
|
68
|
+
compiler.options.plugins = compiler.options.plugins || [];
|
|
69
|
+
compiler.options.plugins.push(new DefinePlugin(replacementValues));
|
|
70
|
+
}
|
|
71
|
+
if (transformAnnotations?.transform) {
|
|
72
|
+
compiler.options.module = compiler.options.module || {};
|
|
73
|
+
compiler.options.module.rules = compiler.options.module.rules || [];
|
|
74
|
+
compiler.options.module.rules.unshift({
|
|
75
|
+
test: /\.[jt]sx$/,
|
|
76
|
+
exclude: /node_modules/,
|
|
77
|
+
enforce: "pre",
|
|
78
|
+
use: [{
|
|
79
|
+
loader: COMPONENT_ANNOTATION_LOADER,
|
|
80
|
+
options: { transform: transformAnnotations.transform }
|
|
81
|
+
}]
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
compiler.hooks.afterEmit.tapAsync("sentry-webpack-plugin", (compilation, callback) => {
|
|
85
|
+
const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
|
|
86
|
+
const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });
|
|
87
|
+
sentryBuildPluginManager.createRelease().then(async () => {
|
|
88
|
+
if (sourcemapsEnabled && options.sourcemaps?.disable !== "disable-upload") {
|
|
89
|
+
const outputPath = compilation.outputOptions.path ?? path.resolve();
|
|
90
|
+
await upload(Object.keys(compilation.assets).map((asset) => path.join(outputPath, asset)));
|
|
91
|
+
}
|
|
92
|
+
}).then(() => {
|
|
93
|
+
callback();
|
|
94
|
+
}).finally(() => {
|
|
95
|
+
freeGlobalDependencyOnBuildArtifacts();
|
|
96
|
+
sentryBuildPluginManager.deleteArtifacts();
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
if (userOptions._experiments?.forceExitOnBuildCompletion && compiler.options.mode === "production") compiler.hooks.done.tap("sentry-webpack-plugin", () => {
|
|
100
|
+
setTimeout(() => {
|
|
101
|
+
logger.debug("Exiting process after debug file upload");
|
|
102
|
+
process.exit(0);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
} };
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
export { sentryWebpackPluginFactory as t };
|
|
110
|
+
|
|
111
|
+
//# sourceMappingURL=webpack4and5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webpack4and5.mjs","names":[],"sources":["../../src/webpack4and5.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 { randomUUID } from \"node:crypto\";\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) : randomUUID();\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"],"mappings":"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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { t as sentryWebpackPluginFactory } from "./webpack4and5.mjs";
|
|
2
|
+
import { sentryCliBinaryExists } from "@sentry/bundler-plugin-core";
|
|
3
|
+
const sentryWebpackPlugin = sentryWebpackPluginFactory();
|
|
4
|
+
//#endregion
|
|
5
|
+
export { sentryCliBinaryExists, sentryWebpackPlugin };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=webpack5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webpack5.mjs","names":[],"sources":["../../src/webpack5.ts"],"sourcesContent":["import { SentryWebpackPluginOptions, sentryWebpackPluginFactory } from \"./webpack4and5\";\n\nconst createSentryWebpackPlugin = sentryWebpackPluginFactory();\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const sentryWebpackPlugin: (options?: SentryWebpackPluginOptions) => any =\n createSentryWebpackPlugin;\n\nexport { sentryCliBinaryExists } from \"@sentry/bundler-plugin-core\";\n\nexport type { SentryWebpackPluginOptions };\n"],"mappings":";;AAKA,MAAa,sBAHqB,4BAA4B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/webpack-plugin",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.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",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"module": "dist/esm/index.mjs",
|
|
35
35
|
"types": "dist/types/index.d.ts",
|
|
36
36
|
"scripts": {
|
|
37
|
-
"build": "premove ./dist && run-p build:rollup build:types",
|
|
37
|
+
"build": "premove ./dist && run-p build:rollup build:types && run-s build:npm",
|
|
38
38
|
"build:watch": "run-p build:rollup:watch build:types:watch",
|
|
39
39
|
"build:rollup": "rolldown --config rollup.config.mjs",
|
|
40
40
|
"build:rollup:watch": "rolldown --config rollup.config.mjs --watch --no-watch.clearScreen",
|
|
@@ -48,30 +48,25 @@
|
|
|
48
48
|
"clean:all": "run-p clean clean:deps",
|
|
49
49
|
"clean:build": "premove ./dist *.tgz",
|
|
50
50
|
"clean:deps": "premove node_modules",
|
|
51
|
-
"test": "
|
|
51
|
+
"test": "vitest run",
|
|
52
52
|
"lint": "eslint ./src ./test",
|
|
53
53
|
"prepack": "ts-node ./src/prepack.ts"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@sentry/bundler-plugin-core": "5.
|
|
57
|
-
"uuid": "^9.0.0"
|
|
56
|
+
"@sentry/bundler-plugin-core": "5.2.0"
|
|
58
57
|
},
|
|
59
58
|
"devDependencies": {
|
|
60
|
-
"@sentry-internal/eslint-config": "5.
|
|
61
|
-
"@sentry-internal/sentry-bundler-plugin-tsconfig": "5.
|
|
62
|
-
"@swc/core": "^1.2.205",
|
|
63
|
-
"@swc/jest": "^0.2.21",
|
|
64
|
-
"@types/jest": "^28.1.3",
|
|
59
|
+
"@sentry-internal/eslint-config": "5.2.0",
|
|
60
|
+
"@sentry-internal/sentry-bundler-plugin-tsconfig": "5.2.0",
|
|
65
61
|
"@types/node": "^18.6.3",
|
|
66
|
-
"@types/uuid": "^9.0.1",
|
|
67
62
|
"@types/webpack": "npm:@types/webpack@^4",
|
|
68
63
|
"eslint": "^8.18.0",
|
|
69
|
-
"
|
|
64
|
+
"vitest": "^4.0.0",
|
|
70
65
|
"premove": "^4.0.0",
|
|
71
|
-
"rolldown": "
|
|
66
|
+
"rolldown": "1.0.0-rc.10",
|
|
72
67
|
"ts-node": "^10.9.1",
|
|
73
68
|
"typescript": "^4.7.4",
|
|
74
|
-
"webpack": "5.
|
|
69
|
+
"webpack": "5.76.0"
|
|
75
70
|
},
|
|
76
71
|
"peerDependencies": {
|
|
77
72
|
"webpack": ">=5.0.0"
|
|
@@ -80,6 +75,6 @@
|
|
|
80
75
|
"extends": "../../package.json"
|
|
81
76
|
},
|
|
82
77
|
"engines": {
|
|
83
|
-
"node": ">=
|
|
78
|
+
"node": ">= 18"
|
|
84
79
|
}
|
|
85
80
|
}
|