@sentry/bundler-plugin-core 4.7.0 → 4.8.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/dist/cjs/index.js +116 -42
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.mjs +117 -44
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/index.d.ts +11 -8
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/options-mapping.d.ts +1 -0
- package/dist/types/options-mapping.d.ts.map +1 -1
- package/dist/types/types.d.ts +5 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts +13 -2
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { transformAsync } from '@babel/core';
|
|
2
|
-
import componentNameAnnotatePlugin from '@sentry/babel-plugin-component-annotate';
|
|
2
|
+
import componentNameAnnotatePlugin, { experimentalComponentNameAnnotatePlugin } from '@sentry/babel-plugin-component-annotate';
|
|
3
3
|
import SentryCli from '@sentry/cli';
|
|
4
4
|
import * as fs from 'fs';
|
|
5
5
|
import fs__default from 'fs';
|
|
@@ -382,6 +382,28 @@ function _asyncToGenerator(fn) {
|
|
|
382
382
|
});
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
|
+
function _classCallCheck(instance, Constructor) {
|
|
386
|
+
if (!(instance instanceof Constructor)) {
|
|
387
|
+
throw new TypeError("Cannot call a class as a function");
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
function _defineProperties(target, props) {
|
|
391
|
+
for (var i = 0; i < props.length; i++) {
|
|
392
|
+
var descriptor = props[i];
|
|
393
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
394
|
+
descriptor.configurable = true;
|
|
395
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
396
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
400
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
401
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
402
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
403
|
+
writable: false
|
|
404
|
+
});
|
|
405
|
+
return Constructor;
|
|
406
|
+
}
|
|
385
407
|
function _defineProperty(obj, key, value) {
|
|
386
408
|
key = _toPropertyKey(key);
|
|
387
409
|
if (key in obj) {
|
|
@@ -7924,25 +7946,19 @@ function determineReleaseName() {
|
|
|
7924
7946
|
function generateGlobalInjectorCode(_ref2) {
|
|
7925
7947
|
var release = _ref2.release,
|
|
7926
7948
|
injectBuildInformation = _ref2.injectBuildInformation;
|
|
7927
|
-
|
|
7928
|
-
// The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
|
|
7929
|
-
var code = "!function(){try{var e=\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:{};";
|
|
7930
|
-
code += "e.SENTRY_RELEASE={id:".concat(JSON.stringify(release), "};");
|
|
7949
|
+
var code = "e.SENTRY_RELEASE={id:".concat(JSON.stringify(release), "};");
|
|
7931
7950
|
if (injectBuildInformation) {
|
|
7932
7951
|
var buildInfo = getBuildInformation();
|
|
7933
7952
|
code += "e.SENTRY_BUILD_INFO=".concat(JSON.stringify(buildInfo), ";");
|
|
7934
7953
|
}
|
|
7935
|
-
|
|
7936
|
-
return code;
|
|
7954
|
+
return new CodeInjection(code);
|
|
7937
7955
|
}
|
|
7938
7956
|
|
|
7939
7957
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7940
7958
|
function generateModuleMetadataInjectorCode(metadata) {
|
|
7941
|
-
// The code below is mostly ternary operators because it saves bundle size.
|
|
7942
|
-
// The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
|
|
7943
7959
|
// We are merging the metadata objects in case modules are bundled twice with the plugin
|
|
7944
7960
|
// Use try-catch to avoid issues when bundlers rename global variables like 'window' to 'k'
|
|
7945
|
-
return
|
|
7961
|
+
return new CodeInjection("e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(null!=a)for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])}return e}({},e._sentryModuleMetadata[(new e.Error).stack],".concat(JSON.stringify(metadata), ");"));
|
|
7946
7962
|
}
|
|
7947
7963
|
function getBuildInformation() {
|
|
7948
7964
|
var packageJson = getPackageJson();
|
|
@@ -8040,6 +8056,51 @@ function containsOnlyImports(code) {
|
|
|
8040
8056
|
.replace(/["']use strict["']\s*;?/g, "").trim();
|
|
8041
8057
|
return codeWithoutImports.length === 0;
|
|
8042
8058
|
}
|
|
8059
|
+
var CodeInjection = /*#__PURE__*/function () {
|
|
8060
|
+
function CodeInjection() {
|
|
8061
|
+
var body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
8062
|
+
_classCallCheck(this, CodeInjection);
|
|
8063
|
+
// The code below is mostly ternary operators because it saves bundle size.
|
|
8064
|
+
// The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)
|
|
8065
|
+
_defineProperty(this, "header", "!function(){try{var e=\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:{};");
|
|
8066
|
+
_defineProperty(this, "footer", "}catch(e){}}();");
|
|
8067
|
+
this.body = body;
|
|
8068
|
+
}
|
|
8069
|
+
_createClass(CodeInjection, [{
|
|
8070
|
+
key: "code",
|
|
8071
|
+
value: function code() {
|
|
8072
|
+
if (this.isEmpty()) {
|
|
8073
|
+
return "";
|
|
8074
|
+
}
|
|
8075
|
+
return this.header + this.body + this.footer;
|
|
8076
|
+
}
|
|
8077
|
+
}, {
|
|
8078
|
+
key: "isEmpty",
|
|
8079
|
+
value: function isEmpty() {
|
|
8080
|
+
return this.body.length === 0;
|
|
8081
|
+
}
|
|
8082
|
+
}, {
|
|
8083
|
+
key: "append",
|
|
8084
|
+
value: function append(code) {
|
|
8085
|
+
if (code instanceof CodeInjection) {
|
|
8086
|
+
this.body += code.body;
|
|
8087
|
+
} else {
|
|
8088
|
+
this.body += code;
|
|
8089
|
+
}
|
|
8090
|
+
}
|
|
8091
|
+
}, {
|
|
8092
|
+
key: "clear",
|
|
8093
|
+
value: function clear() {
|
|
8094
|
+
this.body = "";
|
|
8095
|
+
}
|
|
8096
|
+
}, {
|
|
8097
|
+
key: "clone",
|
|
8098
|
+
value: function clone() {
|
|
8099
|
+
return new CodeInjection(this.body);
|
|
8100
|
+
}
|
|
8101
|
+
}]);
|
|
8102
|
+
return CodeInjection;
|
|
8103
|
+
}();
|
|
8043
8104
|
|
|
8044
8105
|
var SENTRY_SAAS_URL = "https://sentry.io";
|
|
8045
8106
|
function normalizeUserOptions(userOptions) {
|
|
@@ -8341,7 +8402,7 @@ function createSentryInstance(options, shouldSendTelemetry, buildTool) {
|
|
|
8341
8402
|
dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
|
|
8342
8403
|
tracesSampleRate: 1,
|
|
8343
8404
|
sampleRate: 1,
|
|
8344
|
-
release: "4.
|
|
8405
|
+
release: "4.8.0",
|
|
8345
8406
|
integrations: [],
|
|
8346
8407
|
tracePropagationTargets: ["sentry.io/api"],
|
|
8347
8408
|
stackParser: stackParser,
|
|
@@ -8950,7 +9011,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
|
|
|
8950
9011
|
});
|
|
8951
9012
|
|
|
8952
9013
|
// Set the User-Agent that Sentry CLI will use when interacting with Sentry
|
|
8953
|
-
process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.
|
|
9014
|
+
process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.8.0");
|
|
8954
9015
|
|
|
8955
9016
|
// Propagate debug flag to Sentry CLI via environment variable
|
|
8956
9017
|
// Only set if not already defined to respect user's explicit configuration
|
|
@@ -9841,7 +9902,7 @@ function sentryUnpluginFactory(_ref) {
|
|
|
9841
9902
|
if (Object.keys(bundleSizeOptimizationReplacementValues).length > 0) {
|
|
9842
9903
|
plugins.push(bundleSizeOptimizationsPlugin(bundleSizeOptimizationReplacementValues));
|
|
9843
9904
|
}
|
|
9844
|
-
var injectionCode =
|
|
9905
|
+
var injectionCode = new CodeInjection();
|
|
9845
9906
|
if (!options.release.inject) {
|
|
9846
9907
|
logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
|
|
9847
9908
|
} else if (!options.release.name) {
|
|
@@ -9852,20 +9913,20 @@ function sentryUnpluginFactory(_ref) {
|
|
|
9852
9913
|
injectBuildInformation: options._experiments.injectBuildInformation || false
|
|
9853
9914
|
});
|
|
9854
9915
|
if (typeof injectionPlugin !== "function") {
|
|
9855
|
-
plugins.push(injectionPlugin.releaseInjectionPlugin(_code));
|
|
9916
|
+
plugins.push(injectionPlugin.releaseInjectionPlugin(_code.code()));
|
|
9856
9917
|
} else {
|
|
9857
|
-
injectionCode
|
|
9918
|
+
injectionCode.append(_code);
|
|
9858
9919
|
}
|
|
9859
9920
|
}
|
|
9860
9921
|
if (Object.keys(sentryBuildPluginManager.bundleMetadata).length > 0) {
|
|
9861
9922
|
var _code2 = generateModuleMetadataInjectorCode(sentryBuildPluginManager.bundleMetadata);
|
|
9862
9923
|
if (typeof injectionPlugin !== "function") {
|
|
9863
|
-
plugins.push(injectionPlugin.moduleMetadataInjectionPlugin(_code2));
|
|
9924
|
+
plugins.push(injectionPlugin.moduleMetadataInjectionPlugin(_code2.code()));
|
|
9864
9925
|
} else {
|
|
9865
|
-
injectionCode
|
|
9926
|
+
injectionCode.append(_code2);
|
|
9866
9927
|
}
|
|
9867
9928
|
}
|
|
9868
|
-
if (typeof injectionPlugin === "function" && (injectionCode
|
|
9929
|
+
if (typeof injectionPlugin === "function" && (!injectionCode.isEmpty() || ((_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.disable) !== true)) {
|
|
9869
9930
|
var _options$sourcemaps2;
|
|
9870
9931
|
plugins.push(injectionPlugin(injectionCode, ((_options$sourcemaps2 = options.sourcemaps) === null || _options$sourcemaps2 === void 0 ? void 0 : _options$sourcemaps2.disable) !== true, logger));
|
|
9871
9932
|
}
|
|
@@ -9913,7 +9974,7 @@ function sentryUnpluginFactory(_ref) {
|
|
|
9913
9974
|
} else if (options.reactComponentAnnotation.enabled && !componentNameAnnotatePlugin) {
|
|
9914
9975
|
logger.warn("The component name annotate plugin is currently not supported by '@sentry/esbuild-plugin'");
|
|
9915
9976
|
} else {
|
|
9916
|
-
componentNameAnnotatePlugin && plugins.push(componentNameAnnotatePlugin(options.reactComponentAnnotation.ignoredComponents));
|
|
9977
|
+
componentNameAnnotatePlugin && plugins.push(componentNameAnnotatePlugin(options.reactComponentAnnotation.ignoredComponents || [], !!options.reactComponentAnnotation._experimentalInjectIntoHtml));
|
|
9917
9978
|
}
|
|
9918
9979
|
}
|
|
9919
9980
|
|
|
@@ -10006,8 +10067,8 @@ function createRollupBundleSizeOptimizationHooks(replacementValues) {
|
|
|
10006
10067
|
}
|
|
10007
10068
|
function createRollupInjectionHooks(injectionCode, debugIds) {
|
|
10008
10069
|
return {
|
|
10009
|
-
renderChunk: function renderChunk(code, chunk) {
|
|
10010
|
-
var _code$match;
|
|
10070
|
+
renderChunk: function renderChunk(code, chunk, _, meta) {
|
|
10071
|
+
var _code$match, _ms$constructor;
|
|
10011
10072
|
if (!isJsFile(chunk.fileName)) {
|
|
10012
10073
|
return null; // returning null means not modifying the chunk at all
|
|
10013
10074
|
}
|
|
@@ -10016,35 +10077,46 @@ function createRollupInjectionHooks(injectionCode, debugIds) {
|
|
|
10016
10077
|
if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {
|
|
10017
10078
|
return null;
|
|
10018
10079
|
}
|
|
10019
|
-
var codeToInject = injectionCode;
|
|
10080
|
+
var codeToInject = injectionCode.clone();
|
|
10020
10081
|
if (debugIds) {
|
|
10021
10082
|
// Check if a debug ID has already been injected to avoid duplicate injection (e.g. by another plugin or Sentry CLI)
|
|
10022
10083
|
var chunkStartSnippet = code.slice(0, 6000);
|
|
10023
10084
|
var chunkEndSnippet = code.slice(-500);
|
|
10024
10085
|
if (!(chunkStartSnippet.includes("_sentryDebugIdIdentifier") || chunkEndSnippet.includes("//# debugId="))) {
|
|
10025
10086
|
var debugId = stringToUUID(code); // generate a deterministic debug ID
|
|
10026
|
-
codeToInject
|
|
10087
|
+
codeToInject.append(getDebugIdSnippet(debugId));
|
|
10027
10088
|
}
|
|
10028
10089
|
}
|
|
10029
|
-
var ms = new MagicString(code, {
|
|
10090
|
+
var ms = (meta === null || meta === void 0 ? void 0 : meta.magicString) || new MagicString(code, {
|
|
10030
10091
|
filename: chunk.fileName
|
|
10031
10092
|
});
|
|
10032
10093
|
var match = (_code$match = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match === void 0 ? void 0 : _code$match[0];
|
|
10033
10094
|
if (match) {
|
|
10034
10095
|
// Add injected code after any comments or "use strict" at the beginning of the bundle.
|
|
10035
|
-
ms.appendLeft(match.length, codeToInject);
|
|
10096
|
+
ms.appendLeft(match.length, codeToInject.code());
|
|
10036
10097
|
} else {
|
|
10037
10098
|
// ms.replace() doesn't work when there is an empty string match (which happens if
|
|
10038
10099
|
// there is neither, a comment, nor a "use strict" at the top of the chunk) so we
|
|
10039
10100
|
// need this special case here.
|
|
10040
|
-
ms.prepend(codeToInject);
|
|
10101
|
+
ms.prepend(codeToInject.code());
|
|
10102
|
+
}
|
|
10103
|
+
|
|
10104
|
+
// Rolldown can pass a native MagicString instance in meta.magicString
|
|
10105
|
+
// https://rolldown.rs/in-depth/native-magic-string#usage-examples
|
|
10106
|
+
if ((ms === null || ms === void 0 ? void 0 : (_ms$constructor = ms.constructor) === null || _ms$constructor === void 0 ? void 0 : _ms$constructor.name) === "BindingMagicString") {
|
|
10107
|
+
// Rolldown docs say to return the magic string instance directly in this case
|
|
10108
|
+
return {
|
|
10109
|
+
code: ms
|
|
10110
|
+
};
|
|
10041
10111
|
}
|
|
10042
10112
|
return {
|
|
10043
10113
|
code: ms.toString(),
|
|
10044
|
-
map
|
|
10045
|
-
|
|
10046
|
-
|
|
10047
|
-
|
|
10114
|
+
get map() {
|
|
10115
|
+
return ms.generateMap({
|
|
10116
|
+
file: chunk.fileName,
|
|
10117
|
+
hires: "boundary"
|
|
10118
|
+
});
|
|
10119
|
+
}
|
|
10048
10120
|
};
|
|
10049
10121
|
}
|
|
10050
10122
|
};
|
|
@@ -10110,11 +10182,11 @@ function createRollupDebugIdUploadHooks(upload, _logger, createDependencyOnBuild
|
|
|
10110
10182
|
}
|
|
10111
10183
|
};
|
|
10112
10184
|
}
|
|
10113
|
-
function createComponentNameAnnotateHooks(ignoredComponents) {
|
|
10185
|
+
function createComponentNameAnnotateHooks(ignoredComponents, injectIntoHtml) {
|
|
10114
10186
|
return {
|
|
10115
10187
|
transform: function transform(code, id) {
|
|
10116
10188
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
10117
|
-
var idWithoutQueryAndHash, parserPlugins, _result$code, result;
|
|
10189
|
+
var idWithoutQueryAndHash, parserPlugins, plugin, _result$code, result;
|
|
10118
10190
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
10119
10191
|
while (1) switch (_context4.prev = _context4.next) {
|
|
10120
10192
|
case 0:
|
|
@@ -10140,10 +10212,11 @@ function createComponentNameAnnotateHooks(ignoredComponents) {
|
|
|
10140
10212
|
} else if (idWithoutQueryAndHash.endsWith(".tsx")) {
|
|
10141
10213
|
parserPlugins.push("jsx", "typescript");
|
|
10142
10214
|
}
|
|
10143
|
-
|
|
10144
|
-
_context4.
|
|
10215
|
+
plugin = injectIntoHtml ? experimentalComponentNameAnnotatePlugin : componentNameAnnotatePlugin;
|
|
10216
|
+
_context4.prev = 8;
|
|
10217
|
+
_context4.next = 11;
|
|
10145
10218
|
return transformAsync(code, {
|
|
10146
|
-
plugins: [[
|
|
10219
|
+
plugins: [[plugin, {
|
|
10147
10220
|
ignoredComponents: ignoredComponents
|
|
10148
10221
|
}]],
|
|
10149
10222
|
filename: id,
|
|
@@ -10157,32 +10230,32 @@ function createComponentNameAnnotateHooks(ignoredComponents) {
|
|
|
10157
10230
|
},
|
|
10158
10231
|
sourceMaps: true
|
|
10159
10232
|
});
|
|
10160
|
-
case
|
|
10233
|
+
case 11:
|
|
10161
10234
|
result = _context4.sent;
|
|
10162
10235
|
return _context4.abrupt("return", {
|
|
10163
10236
|
code: (_result$code = result === null || result === void 0 ? void 0 : result.code) !== null && _result$code !== void 0 ? _result$code : code,
|
|
10164
10237
|
map: result === null || result === void 0 ? void 0 : result.map
|
|
10165
10238
|
});
|
|
10166
|
-
case
|
|
10167
|
-
_context4.prev =
|
|
10168
|
-
_context4.t0 = _context4["catch"](
|
|
10239
|
+
case 15:
|
|
10240
|
+
_context4.prev = 15;
|
|
10241
|
+
_context4.t0 = _context4["catch"](8);
|
|
10169
10242
|
logger.error("Failed to apply react annotate plugin", _context4.t0);
|
|
10170
|
-
case
|
|
10243
|
+
case 18:
|
|
10171
10244
|
return _context4.abrupt("return", {
|
|
10172
10245
|
code: code
|
|
10173
10246
|
});
|
|
10174
|
-
case
|
|
10247
|
+
case 19:
|
|
10175
10248
|
case "end":
|
|
10176
10249
|
return _context4.stop();
|
|
10177
10250
|
}
|
|
10178
|
-
}, _callee4, null, [[
|
|
10251
|
+
}, _callee4, null, [[8, 15]]);
|
|
10179
10252
|
}))();
|
|
10180
10253
|
}
|
|
10181
10254
|
};
|
|
10182
10255
|
}
|
|
10183
10256
|
function getDebugIdSnippet(debugId) {
|
|
10184
|
-
return "
|
|
10257
|
+
return new CodeInjection("var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]=\"".concat(debugId, "\",e._sentryDebugIdIdentifier=\"sentry-dbid-").concat(debugId, "\");"));
|
|
10185
10258
|
}
|
|
10186
10259
|
|
|
10187
|
-
export { createComponentNameAnnotateHooks, createRollupBundleSizeOptimizationHooks, createRollupDebugIdUploadHooks, createRollupInjectionHooks, createSentryBuildPluginManager, getDebugIdSnippet, replaceBooleanFlagsInCode, sentryCliBinaryExists, sentryUnpluginFactory, stringToUUID };
|
|
10260
|
+
export { CodeInjection, createComponentNameAnnotateHooks, createRollupBundleSizeOptimizationHooks, createRollupDebugIdUploadHooks, createRollupInjectionHooks, createSentryBuildPluginManager, getDebugIdSnippet, replaceBooleanFlagsInCode, sentryCliBinaryExists, sentryUnpluginFactory, stringToUUID };
|
|
10188
10261
|
//# sourceMappingURL=index.mjs.map
|