@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/esm/index.mjs
CHANGED
|
@@ -540,17 +540,20 @@ function stringToUUID(str) {
|
|
|
540
540
|
var v4variant = ["8", "9", "a", "b"][md5Hash.substring(16, 17).charCodeAt(0) % 4];
|
|
541
541
|
return (md5Hash.substring(0, 8) + "-" + md5Hash.substring(8, 12) + "-4" + md5Hash.substring(13, 16) + "-" + v4variant + md5Hash.substring(17, 20) + "-" + md5Hash.substring(20)).toLowerCase();
|
|
542
542
|
}
|
|
543
|
-
|
|
544
|
-
/**
|
|
545
|
-
* Tries to guess a release name based on environmental data.
|
|
546
|
-
*/
|
|
547
|
-
function determineReleaseName() {
|
|
543
|
+
function gitRevision() {
|
|
548
544
|
var gitRevision;
|
|
549
545
|
try {
|
|
550
546
|
gitRevision = childProcess.execSync("git rev-parse HEAD").toString().trim();
|
|
551
547
|
} catch (e) {
|
|
552
548
|
// noop
|
|
553
549
|
}
|
|
550
|
+
return gitRevision;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Tries to guess a release name based on environmental data.
|
|
555
|
+
*/
|
|
556
|
+
function determineReleaseName() {
|
|
554
557
|
return (
|
|
555
558
|
// GitHub Actions - https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
|
|
556
559
|
process.env["GITHUB_SHA"] ||
|
|
@@ -560,12 +563,16 @@ function determineReleaseName() {
|
|
|
560
563
|
process.env["CF_PAGES_COMMIT_SHA"] ||
|
|
561
564
|
// AWS CodeBuild - https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
|
|
562
565
|
process.env["CODEBUILD_RESOLVED_SOURCE_VERSION"] ||
|
|
566
|
+
// Bitbucket - https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/
|
|
567
|
+
process.env["BITBUCKET_COMMIT"] ||
|
|
563
568
|
// CircleCI - https://circleci.com/docs/2.0/env-vars/
|
|
564
569
|
process.env["CIRCLE_SHA1"] ||
|
|
565
570
|
// Vercel - https://vercel.com/docs/v2/build-step#system-environment-variables
|
|
566
571
|
process.env["VERCEL_GIT_COMMIT_SHA"] || process.env["VERCEL_GITHUB_COMMIT_SHA"] || process.env["VERCEL_GITLAB_COMMIT_SHA"] || process.env["VERCEL_BITBUCKET_COMMIT_SHA"] ||
|
|
567
572
|
// Zeit (now known as Vercel)
|
|
568
|
-
process.env["ZEIT_GITHUB_COMMIT_SHA"] || process.env["ZEIT_GITLAB_COMMIT_SHA"] || process.env["ZEIT_BITBUCKET_COMMIT_SHA"] ||
|
|
573
|
+
process.env["ZEIT_GITHUB_COMMIT_SHA"] || process.env["ZEIT_GITLAB_COMMIT_SHA"] || process.env["ZEIT_BITBUCKET_COMMIT_SHA"] ||
|
|
574
|
+
// Flightcontrol - https://www.flightcontrol.dev/docs/guides/flightcontrol/environment-variables#built-in-environment-variables
|
|
575
|
+
process.env["FC_GIT_COMMIT_SHA"] || gitRevision()
|
|
569
576
|
);
|
|
570
577
|
}
|
|
571
578
|
|
|
@@ -610,6 +617,24 @@ function stripQueryAndHashFromPath(path) {
|
|
|
610
617
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
611
618
|
return path.split("?")[0].split("#")[0];
|
|
612
619
|
}
|
|
620
|
+
function replaceBooleanFlagsInCode(code, replacementValues) {
|
|
621
|
+
var ms = new MagicString(code);
|
|
622
|
+
Object.keys(replacementValues).forEach(function (key) {
|
|
623
|
+
var value = replacementValues[key];
|
|
624
|
+
if (typeof value === "boolean") {
|
|
625
|
+
ms.replaceAll(key, JSON.stringify(value));
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
if (ms.hasChanged()) {
|
|
629
|
+
return {
|
|
630
|
+
code: ms.toString(),
|
|
631
|
+
map: ms.generateMap({
|
|
632
|
+
hires: true
|
|
633
|
+
})
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
return null;
|
|
637
|
+
}
|
|
613
638
|
|
|
614
639
|
var SENTRY_SAAS_URL = "https://sentry.io";
|
|
615
640
|
function normalizeUserOptions(userOptions) {
|
|
@@ -634,6 +659,7 @@ function normalizeUserOptions(userOptions) {
|
|
|
634
659
|
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",
|
|
635
660
|
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
|
|
636
661
|
}),
|
|
662
|
+
bundleSizeOptimizations: userOptions.bundleSizeOptimizations,
|
|
637
663
|
_experiments: (_userOptions$_experim = userOptions._experiments) !== null && _userOptions$_experim !== void 0 ? _userOptions$_experim : {}
|
|
638
664
|
};
|
|
639
665
|
return options;
|
|
@@ -1011,7 +1037,7 @@ function _determineSourceMapPathFromBundle() {
|
|
|
1011
1037
|
// 1. try to find source map at `sourceMappingURL` location
|
|
1012
1038
|
sourceMappingUrlMatch = bundleSource.match(/^\s*\/\/# sourceMappingURL=(.*)$/m);
|
|
1013
1039
|
if (!sourceMappingUrlMatch) {
|
|
1014
|
-
_context6.next =
|
|
1040
|
+
_context6.next = 14;
|
|
1015
1041
|
break;
|
|
1016
1042
|
}
|
|
1017
1043
|
sourceMappingUrl = path__default.normalize(sourceMappingUrlMatch[1]);
|
|
@@ -1023,53 +1049,44 @@ function _determineSourceMapPathFromBundle() {
|
|
|
1023
1049
|
isUrl = false;
|
|
1024
1050
|
isSupportedUrl = false;
|
|
1025
1051
|
}
|
|
1026
|
-
if (
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
}
|
|
1030
|
-
absoluteSourceMapPath = sourceMappingUrl;
|
|
1031
|
-
_context6.next = 13;
|
|
1032
|
-
break;
|
|
1033
|
-
case 8:
|
|
1034
|
-
if (!isUrl) {
|
|
1035
|
-
_context6.next = 12;
|
|
1036
|
-
break;
|
|
1037
|
-
}
|
|
1038
|
-
return _context6.abrupt("return");
|
|
1039
|
-
case 12:
|
|
1040
|
-
if (path__default.isAbsolute(sourceMappingUrl)) {
|
|
1052
|
+
if (isSupportedUrl) {
|
|
1053
|
+
absoluteSourceMapPath = sourceMappingUrl;
|
|
1054
|
+
} else if (isUrl) ; else if (path__default.isAbsolute(sourceMappingUrl)) {
|
|
1041
1055
|
absoluteSourceMapPath = sourceMappingUrl;
|
|
1042
1056
|
} else {
|
|
1043
1057
|
absoluteSourceMapPath = path__default.join(path__default.dirname(bundlePath), sourceMappingUrl);
|
|
1044
1058
|
}
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1059
|
+
if (!absoluteSourceMapPath) {
|
|
1060
|
+
_context6.next = 14;
|
|
1061
|
+
break;
|
|
1062
|
+
}
|
|
1063
|
+
_context6.prev = 6;
|
|
1064
|
+
_context6.next = 9;
|
|
1048
1065
|
return util.promisify(fs__default.access)(absoluteSourceMapPath);
|
|
1049
|
-
case
|
|
1066
|
+
case 9:
|
|
1050
1067
|
return _context6.abrupt("return", absoluteSourceMapPath);
|
|
1051
|
-
case
|
|
1052
|
-
_context6.prev =
|
|
1053
|
-
_context6.t0 = _context6["catch"](
|
|
1054
|
-
case
|
|
1055
|
-
_context6.prev =
|
|
1068
|
+
case 12:
|
|
1069
|
+
_context6.prev = 12;
|
|
1070
|
+
_context6.t0 = _context6["catch"](6);
|
|
1071
|
+
case 14:
|
|
1072
|
+
_context6.prev = 14;
|
|
1056
1073
|
adjacentSourceMapFilePath = bundlePath + ".map";
|
|
1057
|
-
_context6.next =
|
|
1074
|
+
_context6.next = 18;
|
|
1058
1075
|
return util.promisify(fs__default.access)(adjacentSourceMapFilePath);
|
|
1059
|
-
case
|
|
1076
|
+
case 18:
|
|
1060
1077
|
return _context6.abrupt("return", adjacentSourceMapFilePath);
|
|
1061
|
-
case
|
|
1062
|
-
_context6.prev =
|
|
1063
|
-
_context6.t1 = _context6["catch"](
|
|
1064
|
-
case
|
|
1078
|
+
case 21:
|
|
1079
|
+
_context6.prev = 21;
|
|
1080
|
+
_context6.t1 = _context6["catch"](14);
|
|
1081
|
+
case 23:
|
|
1065
1082
|
// This is just a debug message because it can be quite spammy for some frameworks
|
|
1066
1083
|
logger.debug("Could not determine source map path for bundle: ".concat(bundlePath, " - Did you turn on source map generation in your bundler?"));
|
|
1067
1084
|
return _context6.abrupt("return", undefined);
|
|
1068
|
-
case
|
|
1085
|
+
case 25:
|
|
1069
1086
|
case "end":
|
|
1070
1087
|
return _context6.stop();
|
|
1071
1088
|
}
|
|
1072
|
-
}, _callee6, null, [[
|
|
1089
|
+
}, _callee6, null, [[6, 12], [14, 21]]);
|
|
1073
1090
|
}));
|
|
1074
1091
|
return _determineSourceMapPathFromBundle.apply(this, arguments);
|
|
1075
1092
|
}
|
|
@@ -1333,7 +1350,7 @@ function createSentryInstance(options, shouldSendTelemetry, bundler) {
|
|
|
1333
1350
|
dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
|
|
1334
1351
|
tracesSampleRate: 1,
|
|
1335
1352
|
sampleRate: 1,
|
|
1336
|
-
release: "2.
|
|
1353
|
+
release: "2.9.0",
|
|
1337
1354
|
integrations: [],
|
|
1338
1355
|
tracePropagationTargets: ["sentry.io/api"],
|
|
1339
1356
|
stackParser: defaultStackParser,
|
|
@@ -1523,7 +1540,8 @@ function sentryUnpluginFactory(_ref) {
|
|
|
1523
1540
|
var releaseInjectionPlugin = _ref.releaseInjectionPlugin,
|
|
1524
1541
|
moduleMetadataInjectionPlugin = _ref.moduleMetadataInjectionPlugin,
|
|
1525
1542
|
debugIdInjectionPlugin = _ref.debugIdInjectionPlugin,
|
|
1526
|
-
debugIdUploadPlugin = _ref.debugIdUploadPlugin
|
|
1543
|
+
debugIdUploadPlugin = _ref.debugIdUploadPlugin,
|
|
1544
|
+
bundleSizeOptimizationsPlugin = _ref.bundleSizeOptimizationsPlugin;
|
|
1527
1545
|
return createUnplugin(function (userOptions, unpluginMetaContext) {
|
|
1528
1546
|
var _userOptions$silent, _userOptions$debug;
|
|
1529
1547
|
var logger = createLogger({
|
|
@@ -1565,7 +1583,7 @@ function sentryUnpluginFactory(_ref) {
|
|
|
1565
1583
|
});
|
|
1566
1584
|
|
|
1567
1585
|
// Set the User-Agent that Sentry CLI will use when interacting with Sentry
|
|
1568
|
-
process.env["SENTRY_PIPELINE"] = "".concat(unpluginMetaContext.framework, "-plugin/", "2.
|
|
1586
|
+
process.env["SENTRY_PIPELINE"] = "".concat(unpluginMetaContext.framework, "-plugin/", "2.9.0");
|
|
1569
1587
|
function handleRecoverableError(unknownError) {
|
|
1570
1588
|
sentrySession.status = "abnormal";
|
|
1571
1589
|
try {
|
|
@@ -1601,6 +1619,28 @@ function sentryUnpluginFactory(_ref) {
|
|
|
1601
1619
|
logger: logger,
|
|
1602
1620
|
shouldSendTelemetry: shouldSendTelemetry
|
|
1603
1621
|
}));
|
|
1622
|
+
if (options.bundleSizeOptimizations) {
|
|
1623
|
+
var bundleSizeOptimizations = options.bundleSizeOptimizations;
|
|
1624
|
+
var replacementValues = {};
|
|
1625
|
+
if (bundleSizeOptimizations.excludeDebugStatements) {
|
|
1626
|
+
replacementValues["__SENTRY_DEBUG__"] = false;
|
|
1627
|
+
}
|
|
1628
|
+
if (bundleSizeOptimizations.excludePerformanceMonitoring) {
|
|
1629
|
+
replacementValues["__SENTRY_TRACE__"] = false;
|
|
1630
|
+
}
|
|
1631
|
+
if (bundleSizeOptimizations.excludeReplayCanvas) {
|
|
1632
|
+
replacementValues["__RRWEB_EXCLUDE_CANVAS__"] = true;
|
|
1633
|
+
}
|
|
1634
|
+
if (bundleSizeOptimizations.excludeReplayIframe) {
|
|
1635
|
+
replacementValues["__RRWEB_EXCLUDE_IFRAME__"] = true;
|
|
1636
|
+
}
|
|
1637
|
+
if (bundleSizeOptimizations.excludeReplayShadowDom) {
|
|
1638
|
+
replacementValues["__RRWEB_EXCLUDE_SHADOW_DOM__"] = true;
|
|
1639
|
+
}
|
|
1640
|
+
if (Object.keys(replacementValues).length > 0) {
|
|
1641
|
+
plugins.push(bundleSizeOptimizationsPlugin(replacementValues));
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1604
1644
|
if (!options.release.inject) {
|
|
1605
1645
|
logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
|
|
1606
1646
|
} else if (!options.release.name) {
|
|
@@ -1771,6 +1811,13 @@ function createRollupReleaseInjectionHooks(injectionCode) {
|
|
|
1771
1811
|
}
|
|
1772
1812
|
};
|
|
1773
1813
|
}
|
|
1814
|
+
function createRollupBundleSizeOptimizationHooks(replacementValues) {
|
|
1815
|
+
return {
|
|
1816
|
+
transform: function transform(code) {
|
|
1817
|
+
return replaceBooleanFlagsInCode(code, replacementValues);
|
|
1818
|
+
}
|
|
1819
|
+
};
|
|
1820
|
+
}
|
|
1774
1821
|
|
|
1775
1822
|
// We need to be careful not to inject the snippet before any `"use strict";`s.
|
|
1776
1823
|
// As an additional complication `"use strict";`s may come after any number of comments.
|
|
@@ -1863,7 +1910,7 @@ function createRollupDebugIdUploadHooks(upload) {
|
|
|
1863
1910
|
}
|
|
1864
1911
|
outputDir = outputOptions.dir;
|
|
1865
1912
|
_context.next = 4;
|
|
1866
|
-
return glob(["/**/*.js", "/**/*.js.map"], {
|
|
1913
|
+
return glob(["/**/*.js", "/**/*.js.map", "/**/*.mjs.map", "/**/*.cjs.map"], {
|
|
1867
1914
|
root: outputDir,
|
|
1868
1915
|
absolute: true,
|
|
1869
1916
|
nodir: true
|
|
@@ -1904,5 +1951,5 @@ function getDebugIdSnippet(debugId) {
|
|
|
1904
1951
|
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){}}();");
|
|
1905
1952
|
}
|
|
1906
1953
|
|
|
1907
|
-
export { createRollupDebugIdInjectionHooks, createRollupDebugIdUploadHooks, createRollupModuleMetadataInjectionHooks, createRollupReleaseInjectionHooks, getBuildInformation, getDebugIdSnippet, sentryCliBinaryExists, sentryUnpluginFactory, stringToUUID };
|
|
1954
|
+
export { createRollupBundleSizeOptimizationHooks, createRollupDebugIdInjectionHooks, createRollupDebugIdUploadHooks, createRollupModuleMetadataInjectionHooks, createRollupReleaseInjectionHooks, getBuildInformation, getDebugIdSnippet, replaceBooleanFlagsInCode, sentryCliBinaryExists, sentryUnpluginFactory, stringToUUID };
|
|
1908
1955
|
//# sourceMappingURL=index.mjs.map
|