@sentry/bundler-plugin-core 2.7.1 → 2.9.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 +92 -43
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.mjs +91 -44
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/index.d.ts +11 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/options-mapping.d.ts +7 -0
- package/dist/types/options-mapping.d.ts.map +1 -1
- package/dist/types/types.d.ts +45 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts +5 -0
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/cjs/index.js
CHANGED
|
@@ -574,17 +574,20 @@ function stringToUUID(str) {
|
|
|
574
574
|
var v4variant = ["8", "9", "a", "b"][md5Hash.substring(16, 17).charCodeAt(0) % 4];
|
|
575
575
|
return (md5Hash.substring(0, 8) + "-" + md5Hash.substring(8, 12) + "-4" + md5Hash.substring(13, 16) + "-" + v4variant + md5Hash.substring(17, 20) + "-" + md5Hash.substring(20)).toLowerCase();
|
|
576
576
|
}
|
|
577
|
-
|
|
578
|
-
/**
|
|
579
|
-
* Tries to guess a release name based on environmental data.
|
|
580
|
-
*/
|
|
581
|
-
function determineReleaseName() {
|
|
577
|
+
function gitRevision() {
|
|
582
578
|
var gitRevision;
|
|
583
579
|
try {
|
|
584
580
|
gitRevision = childProcess__default["default"].execSync("git rev-parse HEAD").toString().trim();
|
|
585
581
|
} catch (e) {
|
|
586
582
|
// noop
|
|
587
583
|
}
|
|
584
|
+
return gitRevision;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Tries to guess a release name based on environmental data.
|
|
589
|
+
*/
|
|
590
|
+
function determineReleaseName() {
|
|
588
591
|
return (
|
|
589
592
|
// GitHub Actions - https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
|
|
590
593
|
process.env["GITHUB_SHA"] ||
|
|
@@ -594,12 +597,16 @@ function determineReleaseName() {
|
|
|
594
597
|
process.env["CF_PAGES_COMMIT_SHA"] ||
|
|
595
598
|
// AWS CodeBuild - https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
|
|
596
599
|
process.env["CODEBUILD_RESOLVED_SOURCE_VERSION"] ||
|
|
600
|
+
// Bitbucket - https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/
|
|
601
|
+
process.env["BITBUCKET_COMMIT"] ||
|
|
597
602
|
// CircleCI - https://circleci.com/docs/2.0/env-vars/
|
|
598
603
|
process.env["CIRCLE_SHA1"] ||
|
|
599
604
|
// Vercel - https://vercel.com/docs/v2/build-step#system-environment-variables
|
|
600
605
|
process.env["VERCEL_GIT_COMMIT_SHA"] || process.env["VERCEL_GITHUB_COMMIT_SHA"] || process.env["VERCEL_GITLAB_COMMIT_SHA"] || process.env["VERCEL_BITBUCKET_COMMIT_SHA"] ||
|
|
601
606
|
// Zeit (now known as Vercel)
|
|
602
|
-
process.env["ZEIT_GITHUB_COMMIT_SHA"] || process.env["ZEIT_GITLAB_COMMIT_SHA"] || process.env["ZEIT_BITBUCKET_COMMIT_SHA"] ||
|
|
607
|
+
process.env["ZEIT_GITHUB_COMMIT_SHA"] || process.env["ZEIT_GITLAB_COMMIT_SHA"] || process.env["ZEIT_BITBUCKET_COMMIT_SHA"] ||
|
|
608
|
+
// Flightcontrol - https://www.flightcontrol.dev/docs/guides/flightcontrol/environment-variables#built-in-environment-variables
|
|
609
|
+
process.env["FC_GIT_COMMIT_SHA"] || gitRevision()
|
|
603
610
|
);
|
|
604
611
|
}
|
|
605
612
|
|
|
@@ -644,6 +651,24 @@ function stripQueryAndHashFromPath(path) {
|
|
|
644
651
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
645
652
|
return path.split("?")[0].split("#")[0];
|
|
646
653
|
}
|
|
654
|
+
function replaceBooleanFlagsInCode(code, replacementValues) {
|
|
655
|
+
var ms = new MagicString__default["default"](code);
|
|
656
|
+
Object.keys(replacementValues).forEach(function (key) {
|
|
657
|
+
var value = replacementValues[key];
|
|
658
|
+
if (typeof value === "boolean") {
|
|
659
|
+
ms.replaceAll(key, JSON.stringify(value));
|
|
660
|
+
}
|
|
661
|
+
});
|
|
662
|
+
if (ms.hasChanged()) {
|
|
663
|
+
return {
|
|
664
|
+
code: ms.toString(),
|
|
665
|
+
map: ms.generateMap({
|
|
666
|
+
hires: true
|
|
667
|
+
})
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
return null;
|
|
671
|
+
}
|
|
647
672
|
|
|
648
673
|
var SENTRY_SAAS_URL = "https://sentry.io";
|
|
649
674
|
function normalizeUserOptions(userOptions) {
|
|
@@ -668,6 +693,7 @@ function normalizeUserOptions(userOptions) {
|
|
|
668
693
|
vcsRemote: (_ref3 = (_userOptions$release$5 = (_userOptions$release5 = userOptions.release) === null || _userOptions$release5 === void 0 ? void 0 : _userOptions$release5.vcsRemote) !== null && _userOptions$release$5 !== void 0 ? _userOptions$release$5 : process.env["SENTRY_VSC_REMOTE"]) !== null && _ref3 !== void 0 ? _ref3 : "origin",
|
|
669
694
|
cleanArtifacts: (_userOptions$release$6 = (_userOptions$release6 = userOptions.release) === null || _userOptions$release6 === void 0 ? void 0 : _userOptions$release6.cleanArtifacts) !== null && _userOptions$release$6 !== void 0 ? _userOptions$release$6 : false
|
|
670
695
|
}),
|
|
696
|
+
bundleSizeOptimizations: userOptions.bundleSizeOptimizations,
|
|
671
697
|
_experiments: (_userOptions$_experim = userOptions._experiments) !== null && _userOptions$_experim !== void 0 ? _userOptions$_experim : {}
|
|
672
698
|
};
|
|
673
699
|
return options;
|
|
@@ -1045,7 +1071,7 @@ function _determineSourceMapPathFromBundle() {
|
|
|
1045
1071
|
// 1. try to find source map at `sourceMappingURL` location
|
|
1046
1072
|
sourceMappingUrlMatch = bundleSource.match(/^\s*\/\/# sourceMappingURL=(.*)$/m);
|
|
1047
1073
|
if (!sourceMappingUrlMatch) {
|
|
1048
|
-
_context6.next =
|
|
1074
|
+
_context6.next = 14;
|
|
1049
1075
|
break;
|
|
1050
1076
|
}
|
|
1051
1077
|
sourceMappingUrl = path__default["default"].normalize(sourceMappingUrlMatch[1]);
|
|
@@ -1057,53 +1083,44 @@ function _determineSourceMapPathFromBundle() {
|
|
|
1057
1083
|
isUrl = false;
|
|
1058
1084
|
isSupportedUrl = false;
|
|
1059
1085
|
}
|
|
1060
|
-
if (
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
}
|
|
1064
|
-
absoluteSourceMapPath = sourceMappingUrl;
|
|
1065
|
-
_context6.next = 13;
|
|
1066
|
-
break;
|
|
1067
|
-
case 8:
|
|
1068
|
-
if (!isUrl) {
|
|
1069
|
-
_context6.next = 12;
|
|
1070
|
-
break;
|
|
1071
|
-
}
|
|
1072
|
-
return _context6.abrupt("return");
|
|
1073
|
-
case 12:
|
|
1074
|
-
if (path__default["default"].isAbsolute(sourceMappingUrl)) {
|
|
1086
|
+
if (isSupportedUrl) {
|
|
1087
|
+
absoluteSourceMapPath = sourceMappingUrl;
|
|
1088
|
+
} else if (isUrl) ; else if (path__default["default"].isAbsolute(sourceMappingUrl)) {
|
|
1075
1089
|
absoluteSourceMapPath = sourceMappingUrl;
|
|
1076
1090
|
} else {
|
|
1077
1091
|
absoluteSourceMapPath = path__default["default"].join(path__default["default"].dirname(bundlePath), sourceMappingUrl);
|
|
1078
1092
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1093
|
+
if (!absoluteSourceMapPath) {
|
|
1094
|
+
_context6.next = 14;
|
|
1095
|
+
break;
|
|
1096
|
+
}
|
|
1097
|
+
_context6.prev = 6;
|
|
1098
|
+
_context6.next = 9;
|
|
1082
1099
|
return util__namespace.promisify(fs__default["default"].access)(absoluteSourceMapPath);
|
|
1083
|
-
case
|
|
1100
|
+
case 9:
|
|
1084
1101
|
return _context6.abrupt("return", absoluteSourceMapPath);
|
|
1085
|
-
case
|
|
1086
|
-
_context6.prev =
|
|
1087
|
-
_context6.t0 = _context6["catch"](
|
|
1088
|
-
case
|
|
1089
|
-
_context6.prev =
|
|
1102
|
+
case 12:
|
|
1103
|
+
_context6.prev = 12;
|
|
1104
|
+
_context6.t0 = _context6["catch"](6);
|
|
1105
|
+
case 14:
|
|
1106
|
+
_context6.prev = 14;
|
|
1090
1107
|
adjacentSourceMapFilePath = bundlePath + ".map";
|
|
1091
|
-
_context6.next =
|
|
1108
|
+
_context6.next = 18;
|
|
1092
1109
|
return util__namespace.promisify(fs__default["default"].access)(adjacentSourceMapFilePath);
|
|
1093
|
-
case
|
|
1110
|
+
case 18:
|
|
1094
1111
|
return _context6.abrupt("return", adjacentSourceMapFilePath);
|
|
1095
|
-
case
|
|
1096
|
-
_context6.prev =
|
|
1097
|
-
_context6.t1 = _context6["catch"](
|
|
1098
|
-
case
|
|
1112
|
+
case 21:
|
|
1113
|
+
_context6.prev = 21;
|
|
1114
|
+
_context6.t1 = _context6["catch"](14);
|
|
1115
|
+
case 23:
|
|
1099
1116
|
// This is just a debug message because it can be quite spammy for some frameworks
|
|
1100
1117
|
logger.debug("Could not determine source map path for bundle: ".concat(bundlePath, " - Did you turn on source map generation in your bundler?"));
|
|
1101
1118
|
return _context6.abrupt("return", undefined);
|
|
1102
|
-
case
|
|
1119
|
+
case 25:
|
|
1103
1120
|
case "end":
|
|
1104
1121
|
return _context6.stop();
|
|
1105
1122
|
}
|
|
1106
|
-
}, _callee6, null, [[
|
|
1123
|
+
}, _callee6, null, [[6, 12], [14, 21]]);
|
|
1107
1124
|
}));
|
|
1108
1125
|
return _determineSourceMapPathFromBundle.apply(this, arguments);
|
|
1109
1126
|
}
|
|
@@ -1367,7 +1384,7 @@ function createSentryInstance(options, shouldSendTelemetry, bundler) {
|
|
|
1367
1384
|
dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
|
|
1368
1385
|
tracesSampleRate: 1,
|
|
1369
1386
|
sampleRate: 1,
|
|
1370
|
-
release: "2.
|
|
1387
|
+
release: "2.9.0",
|
|
1371
1388
|
integrations: [],
|
|
1372
1389
|
tracePropagationTargets: ["sentry.io/api"],
|
|
1373
1390
|
stackParser: node.defaultStackParser,
|
|
@@ -1557,7 +1574,8 @@ function sentryUnpluginFactory(_ref) {
|
|
|
1557
1574
|
var releaseInjectionPlugin = _ref.releaseInjectionPlugin,
|
|
1558
1575
|
moduleMetadataInjectionPlugin = _ref.moduleMetadataInjectionPlugin,
|
|
1559
1576
|
debugIdInjectionPlugin = _ref.debugIdInjectionPlugin,
|
|
1560
|
-
debugIdUploadPlugin = _ref.debugIdUploadPlugin
|
|
1577
|
+
debugIdUploadPlugin = _ref.debugIdUploadPlugin,
|
|
1578
|
+
bundleSizeOptimizationsPlugin = _ref.bundleSizeOptimizationsPlugin;
|
|
1561
1579
|
return unplugin.createUnplugin(function (userOptions, unpluginMetaContext) {
|
|
1562
1580
|
var _userOptions$silent, _userOptions$debug;
|
|
1563
1581
|
var logger = createLogger({
|
|
@@ -1599,7 +1617,7 @@ function sentryUnpluginFactory(_ref) {
|
|
|
1599
1617
|
});
|
|
1600
1618
|
|
|
1601
1619
|
// Set the User-Agent that Sentry CLI will use when interacting with Sentry
|
|
1602
|
-
process.env["SENTRY_PIPELINE"] = "".concat(unpluginMetaContext.framework, "-plugin/", "2.
|
|
1620
|
+
process.env["SENTRY_PIPELINE"] = "".concat(unpluginMetaContext.framework, "-plugin/", "2.9.0");
|
|
1603
1621
|
function handleRecoverableError(unknownError) {
|
|
1604
1622
|
sentrySession.status = "abnormal";
|
|
1605
1623
|
try {
|
|
@@ -1635,6 +1653,28 @@ function sentryUnpluginFactory(_ref) {
|
|
|
1635
1653
|
logger: logger,
|
|
1636
1654
|
shouldSendTelemetry: shouldSendTelemetry
|
|
1637
1655
|
}));
|
|
1656
|
+
if (options.bundleSizeOptimizations) {
|
|
1657
|
+
var bundleSizeOptimizations = options.bundleSizeOptimizations;
|
|
1658
|
+
var replacementValues = {};
|
|
1659
|
+
if (bundleSizeOptimizations.excludeDebugStatements) {
|
|
1660
|
+
replacementValues["__SENTRY_DEBUG__"] = false;
|
|
1661
|
+
}
|
|
1662
|
+
if (bundleSizeOptimizations.excludePerformanceMonitoring) {
|
|
1663
|
+
replacementValues["__SENTRY_TRACE__"] = false;
|
|
1664
|
+
}
|
|
1665
|
+
if (bundleSizeOptimizations.excludeReplayCanvas) {
|
|
1666
|
+
replacementValues["__RRWEB_EXCLUDE_CANVAS__"] = true;
|
|
1667
|
+
}
|
|
1668
|
+
if (bundleSizeOptimizations.excludeReplayIframe) {
|
|
1669
|
+
replacementValues["__RRWEB_EXCLUDE_IFRAME__"] = true;
|
|
1670
|
+
}
|
|
1671
|
+
if (bundleSizeOptimizations.excludeReplayShadowDom) {
|
|
1672
|
+
replacementValues["__RRWEB_EXCLUDE_SHADOW_DOM__"] = true;
|
|
1673
|
+
}
|
|
1674
|
+
if (Object.keys(replacementValues).length > 0) {
|
|
1675
|
+
plugins.push(bundleSizeOptimizationsPlugin(replacementValues));
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1638
1678
|
if (!options.release.inject) {
|
|
1639
1679
|
logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
|
|
1640
1680
|
} else if (!options.release.name) {
|
|
@@ -1805,6 +1845,13 @@ function createRollupReleaseInjectionHooks(injectionCode) {
|
|
|
1805
1845
|
}
|
|
1806
1846
|
};
|
|
1807
1847
|
}
|
|
1848
|
+
function createRollupBundleSizeOptimizationHooks(replacementValues) {
|
|
1849
|
+
return {
|
|
1850
|
+
transform: function transform(code) {
|
|
1851
|
+
return replaceBooleanFlagsInCode(code, replacementValues);
|
|
1852
|
+
}
|
|
1853
|
+
};
|
|
1854
|
+
}
|
|
1808
1855
|
|
|
1809
1856
|
// We need to be careful not to inject the snippet before any `"use strict";`s.
|
|
1810
1857
|
// As an additional complication `"use strict";`s may come after any number of comments.
|
|
@@ -1897,7 +1944,7 @@ function createRollupDebugIdUploadHooks(upload) {
|
|
|
1897
1944
|
}
|
|
1898
1945
|
outputDir = outputOptions.dir;
|
|
1899
1946
|
_context.next = 4;
|
|
1900
|
-
return glob.glob(["/**/*.js", "/**/*.js.map"], {
|
|
1947
|
+
return glob.glob(["/**/*.js", "/**/*.js.map", "/**/*.mjs.map", "/**/*.cjs.map"], {
|
|
1901
1948
|
root: outputDir,
|
|
1902
1949
|
absolute: true,
|
|
1903
1950
|
nodir: true
|
|
@@ -1938,12 +1985,14 @@ function getDebugIdSnippet(debugId) {
|
|
|
1938
1985
|
return ";!function(){try{var e=\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]=\"".concat(debugId, "\",e._sentryDebugIdIdentifier=\"sentry-dbid-").concat(debugId, "\")}catch(e){}}();");
|
|
1939
1986
|
}
|
|
1940
1987
|
|
|
1988
|
+
exports.createRollupBundleSizeOptimizationHooks = createRollupBundleSizeOptimizationHooks;
|
|
1941
1989
|
exports.createRollupDebugIdInjectionHooks = createRollupDebugIdInjectionHooks;
|
|
1942
1990
|
exports.createRollupDebugIdUploadHooks = createRollupDebugIdUploadHooks;
|
|
1943
1991
|
exports.createRollupModuleMetadataInjectionHooks = createRollupModuleMetadataInjectionHooks;
|
|
1944
1992
|
exports.createRollupReleaseInjectionHooks = createRollupReleaseInjectionHooks;
|
|
1945
1993
|
exports.getBuildInformation = getBuildInformation;
|
|
1946
1994
|
exports.getDebugIdSnippet = getDebugIdSnippet;
|
|
1995
|
+
exports.replaceBooleanFlagsInCode = replaceBooleanFlagsInCode;
|
|
1947
1996
|
exports.sentryCliBinaryExists = sentryCliBinaryExists;
|
|
1948
1997
|
exports.sentryUnpluginFactory = sentryUnpluginFactory;
|
|
1949
1998
|
exports.stringToUUID = stringToUUID;
|