@sentry/bundler-plugin-core 0.2.4 → 0.4.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 +83 -120
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.mjs +83 -120
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/options-mapping.d.ts +1 -1
- package/dist/types/types.d.ts +4 -8
- package/package.json +5 -5
package/dist/esm/index.mjs
CHANGED
|
@@ -765,7 +765,7 @@ function arrayify(maybeArray) {
|
|
|
765
765
|
|
|
766
766
|
var SENTRY_SAAS_URL = "https://sentry.io";
|
|
767
767
|
function normalizeUserOptions(userOptions) {
|
|
768
|
-
var _userOptions$org, _userOptions$project, _ref, _userOptions$release, _ref2, _userOptions$url, _userOptions$finalize, _userOptions$cleanArt, _userOptions$dryRun, _userOptions$debug, _userOptions$silent, _userOptions$telemetr, _userOptions$injectRe
|
|
768
|
+
var _userOptions$org, _userOptions$project, _ref, _userOptions$release, _ref2, _userOptions$url, _userOptions$finalize, _userOptions$cleanArt, _userOptions$dryRun, _userOptions$debug, _userOptions$silent, _userOptions$telemetr, _userOptions$injectRe;
|
|
769
769
|
|
|
770
770
|
var options = {
|
|
771
771
|
// include is the only strictly required option
|
|
@@ -800,10 +800,7 @@ function normalizeUserOptions(userOptions) {
|
|
|
800
800
|
// the passed options are undefined.
|
|
801
801
|
authToken: userOptions.authToken,
|
|
802
802
|
// env var: `SENTRY_AUTH_TOKEN`
|
|
803
|
-
|
|
804
|
-
// but CLI v2 uses `SENTRY_HEADER` (which is also better aligned with other naming)
|
|
805
|
-
// In the spirit of maximum compatibility, we allow both here.
|
|
806
|
-
customHeader: (_ref3 = (_userOptions$customHe = userOptions.customHeader) !== null && _userOptions$customHe !== void 0 ? _userOptions$customHe : process.env["SENTRY_HEADER"]) !== null && _ref3 !== void 0 ? _ref3 : process.env["CUSTOM_HEADER"],
|
|
803
|
+
headers: userOptions.headers,
|
|
807
804
|
vcsRemote: userOptions.vcsRemote,
|
|
808
805
|
// env var: `SENTRY_VSC_REMOTE`
|
|
809
806
|
// Optional options
|
|
@@ -862,12 +859,12 @@ function normalizeInclude(userOptions) {
|
|
|
862
859
|
|
|
863
860
|
|
|
864
861
|
function normalizeIncludeEntry(userOptions, includeEntry) {
|
|
865
|
-
var
|
|
862
|
+
var _ref3, _includeEntry$ignore, _ref4, _includeEntry$ext, _includeEntry$ignoreF, _includeEntry$urlPref, _includeEntry$urlSuff, _includeEntry$stripPr, _ref5, _includeEntry$stripCo, _ref6, _includeEntry$sourceM, _ref7, _includeEntry$rewrite, _ref8, _includeEntry$validat;
|
|
866
863
|
|
|
867
|
-
var ignoreOption = (
|
|
864
|
+
var ignoreOption = (_ref3 = (_includeEntry$ignore = includeEntry.ignore) !== null && _includeEntry$ignore !== void 0 ? _includeEntry$ignore : userOptions.ignore) !== null && _ref3 !== void 0 ? _ref3 : ["node_modules"];
|
|
868
865
|
var ignore = Array.isArray(ignoreOption) ? ignoreOption : [ignoreOption]; // We're prefixing all entries in the `ext` option with a `.` (if it isn't already) to align with Node.js' `path.extname()`
|
|
869
866
|
|
|
870
|
-
var ext = (
|
|
867
|
+
var ext = (_ref4 = (_includeEntry$ext = includeEntry.ext) !== null && _includeEntry$ext !== void 0 ? _includeEntry$ext : userOptions.ext) !== null && _ref4 !== void 0 ? _ref4 : ["js", "map", "jsbundle", "bundle"];
|
|
871
868
|
var dotPrefixedExt = ext.map(function (extension) {
|
|
872
869
|
return ".".concat(extension.replace(/^\./, ""));
|
|
873
870
|
});
|
|
@@ -879,10 +876,10 @@ function normalizeIncludeEntry(userOptions, includeEntry) {
|
|
|
879
876
|
urlPrefix: (_includeEntry$urlPref = includeEntry.urlPrefix) !== null && _includeEntry$urlPref !== void 0 ? _includeEntry$urlPref : userOptions.urlPrefix,
|
|
880
877
|
urlSuffix: (_includeEntry$urlSuff = includeEntry.urlSuffix) !== null && _includeEntry$urlSuff !== void 0 ? _includeEntry$urlSuff : userOptions.urlSuffix,
|
|
881
878
|
stripPrefix: (_includeEntry$stripPr = includeEntry.stripPrefix) !== null && _includeEntry$stripPr !== void 0 ? _includeEntry$stripPr : userOptions.stripPrefix,
|
|
882
|
-
stripCommonPrefix: (
|
|
883
|
-
sourceMapReference: (
|
|
884
|
-
rewrite: (
|
|
885
|
-
validate: (
|
|
879
|
+
stripCommonPrefix: (_ref5 = (_includeEntry$stripCo = includeEntry.stripCommonPrefix) !== null && _includeEntry$stripCo !== void 0 ? _includeEntry$stripCo : userOptions.stripCommonPrefix) !== null && _ref5 !== void 0 ? _ref5 : false,
|
|
880
|
+
sourceMapReference: (_ref6 = (_includeEntry$sourceM = includeEntry.sourceMapReference) !== null && _includeEntry$sourceM !== void 0 ? _includeEntry$sourceM : userOptions.sourceMapReference) !== null && _ref6 !== void 0 ? _ref6 : true,
|
|
881
|
+
rewrite: (_ref7 = (_includeEntry$rewrite = includeEntry.rewrite) !== null && _includeEntry$rewrite !== void 0 ? _includeEntry$rewrite : userOptions.rewrite) !== null && _ref7 !== void 0 ? _ref7 : true,
|
|
882
|
+
validate: (_ref8 = (_includeEntry$validat = includeEntry.validate) !== null && _includeEntry$validat !== void 0 ? _includeEntry$validat : userOptions.validate) !== null && _ref8 !== void 0 ? _ref8 : false
|
|
886
883
|
};
|
|
887
884
|
}
|
|
888
885
|
/**
|
|
@@ -936,7 +933,7 @@ function makeSentryClient(dsn, allowedToSendTelemetryPromise, userProject) {
|
|
|
936
933
|
// a dashboard.
|
|
937
934
|
// Yes, this is slightly abusing the purpose of this field.
|
|
938
935
|
dist: userProject,
|
|
939
|
-
release: "0.
|
|
936
|
+
release: "0.4.0",
|
|
940
937
|
integrations: [],
|
|
941
938
|
tracePropagationTargets: ["sentry.io/api"],
|
|
942
939
|
stackParser: defaultStackParser,
|
|
@@ -1088,12 +1085,12 @@ function _shouldSendTelemetry() {
|
|
|
1088
1085
|
_shouldSendTelemetry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
1089
1086
|
var _cliInfo$split$, _cliInfo$split$$repla;
|
|
1090
1087
|
|
|
1091
|
-
var silent, org, project, authToken, url, vcsRemote,
|
|
1088
|
+
var silent, org, project, authToken, url, vcsRemote, headers, telemetry, dryRun, cli, cliInfo, cliInfoUrl;
|
|
1092
1089
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1093
1090
|
while (1) {
|
|
1094
1091
|
switch (_context2.prev = _context2.next) {
|
|
1095
1092
|
case 0:
|
|
1096
|
-
silent = options.silent, org = options.org, project = options.project, authToken = options.authToken, url = options.url, vcsRemote = options.vcsRemote,
|
|
1093
|
+
silent = options.silent, org = options.org, project = options.project, authToken = options.authToken, url = options.url, vcsRemote = options.vcsRemote, headers = options.headers, telemetry = options.telemetry, dryRun = options.dryRun; // `options.telemetry` defaults to true
|
|
1097
1094
|
|
|
1098
1095
|
if (!(telemetry === false)) {
|
|
1099
1096
|
_context2.next = 3;
|
|
@@ -1125,9 +1122,8 @@ function _shouldSendTelemetry() {
|
|
|
1125
1122
|
org: org,
|
|
1126
1123
|
project: project,
|
|
1127
1124
|
vcsRemote: vcsRemote,
|
|
1128
|
-
dist: dist,
|
|
1129
1125
|
silent: silent,
|
|
1130
|
-
|
|
1126
|
+
headers: headers
|
|
1131
1127
|
});
|
|
1132
1128
|
_context2.prev = 8;
|
|
1133
1129
|
_context2.next = 11;
|
|
@@ -1289,7 +1285,8 @@ function _uploadSourceMaps() {
|
|
|
1289
1285
|
_context3.prev = 2;
|
|
1290
1286
|
_context3.next = 5;
|
|
1291
1287
|
return ctx.cli.releases.uploadSourceMaps(releaseName, {
|
|
1292
|
-
include: options.include
|
|
1288
|
+
include: options.include,
|
|
1289
|
+
dist: options.dist
|
|
1293
1290
|
});
|
|
1294
1291
|
|
|
1295
1292
|
case 5:
|
|
@@ -1583,17 +1580,15 @@ function getSentryCli(internalOptions, logger) {
|
|
|
1583
1580
|
authToken = internalOptions.authToken,
|
|
1584
1581
|
url = internalOptions.url,
|
|
1585
1582
|
vcsRemote = internalOptions.vcsRemote,
|
|
1586
|
-
|
|
1587
|
-
dist = internalOptions.dist;
|
|
1583
|
+
headers = internalOptions.headers;
|
|
1588
1584
|
var cli = new SentryCli(internalOptions.configFile, {
|
|
1589
1585
|
url: url,
|
|
1590
1586
|
authToken: authToken,
|
|
1591
1587
|
org: org,
|
|
1592
1588
|
project: project,
|
|
1593
1589
|
vcsRemote: vcsRemote,
|
|
1594
|
-
dist: dist,
|
|
1595
1590
|
silent: silent,
|
|
1596
|
-
|
|
1591
|
+
headers: headers
|
|
1597
1592
|
});
|
|
1598
1593
|
|
|
1599
1594
|
if (internalOptions.dryRun) {
|
|
@@ -1645,10 +1640,6 @@ function getDryRunCLI(cli, logger) {
|
|
|
1645
1640
|
};
|
|
1646
1641
|
}
|
|
1647
1642
|
|
|
1648
|
-
// This hack is taken straight from https://rollupjs.org/guide/en/#resolveid.
|
|
1649
|
-
// This probably doesn't work for all bundlers but for rollup it does.
|
|
1650
|
-
|
|
1651
|
-
var RELEASE_INJECTOR_ID = "\0sentry-release-injector";
|
|
1652
1643
|
var ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".mjs"];
|
|
1653
1644
|
/**
|
|
1654
1645
|
* The sentry bundler plugin concerns itself with two things:
|
|
@@ -1656,17 +1647,17 @@ var ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".mjs"]
|
|
|
1656
1647
|
* - Sourcemaps upload
|
|
1657
1648
|
*
|
|
1658
1649
|
* Release injection:
|
|
1659
|
-
*
|
|
1660
|
-
*
|
|
1661
|
-
*
|
|
1662
|
-
*
|
|
1663
|
-
*
|
|
1664
|
-
* If a user wants to inject the release into a particular set of modules they can use the `releaseInjectionTargets` option.
|
|
1650
|
+
* Per default the sentry bundler plugin will inject a global `SENTRY_RELEASE` into
|
|
1651
|
+
* each JavaScript/TypeScript entrypoint. On a technical level this is done by identifying
|
|
1652
|
+
* entrypoints in the `resolveId` hook and prepending user code in the `transform` hook.
|
|
1653
|
+
* If a user wants to inject the release into a particular set of modules instead,
|
|
1654
|
+
* they can use the `releaseInjectionTargets` option.
|
|
1665
1655
|
*
|
|
1666
1656
|
* Source maps upload:
|
|
1667
1657
|
*
|
|
1668
|
-
* The sentry bundler plugin will also take care of uploading source maps to Sentry. This
|
|
1669
|
-
* `writeBundle` hook. In this hook the sentry plugin will execute the
|
|
1658
|
+
* The sentry bundler plugin will also take care of uploading source maps to Sentry. This
|
|
1659
|
+
* is all done in the `writeBundle` hook. In this hook the sentry plugin will execute the
|
|
1660
|
+
* release creation pipeline:
|
|
1670
1661
|
*
|
|
1671
1662
|
* 1. Create a new release
|
|
1672
1663
|
* 2. Delete already uploaded artifacts for this release (if `cleanArtifacts` is enabled)
|
|
@@ -1713,6 +1704,7 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1713
1704
|
});
|
|
1714
1705
|
var transaction;
|
|
1715
1706
|
var releaseInjectionSpan;
|
|
1707
|
+
var absolueEntrypointPaths = new Set();
|
|
1716
1708
|
return {
|
|
1717
1709
|
name: "sentry-plugin",
|
|
1718
1710
|
enforce: "pre",
|
|
@@ -1799,68 +1791,11 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1799
1791
|
isEntry: isEntry
|
|
1800
1792
|
});
|
|
1801
1793
|
|
|
1802
|
-
if (
|
|
1803
|
-
|
|
1804
|
-
} else {
|
|
1805
|
-
return undefined;
|
|
1794
|
+
if (isEntry) {
|
|
1795
|
+
absolueEntrypointPaths.add(path.resolve(path.normalize(id)));
|
|
1806
1796
|
}
|
|
1807
|
-
},
|
|
1808
|
-
loadInclude: function loadInclude(id) {
|
|
1809
|
-
logger.debug('Called "loadInclude":', {
|
|
1810
|
-
id: id
|
|
1811
|
-
});
|
|
1812
|
-
return id === RELEASE_INJECTOR_ID;
|
|
1813
|
-
},
|
|
1814
1797
|
|
|
1815
|
-
|
|
1816
|
-
* Responsible for "virtually" loading the "sentry-release-injector" module. "Virtual" means that the module is not
|
|
1817
|
-
* read from somewhere on disk but rather just returned via a string.
|
|
1818
|
-
*
|
|
1819
|
-
* @param id Always the absolute (fully resolved) path to the module.
|
|
1820
|
-
* @returns The global injector code when we load the "sentry-release-injector" module. Otherwise returns `undefined`.
|
|
1821
|
-
*/
|
|
1822
|
-
load: function load(id) {
|
|
1823
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
1824
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1825
|
-
while (1) {
|
|
1826
|
-
switch (_context2.prev = _context2.next) {
|
|
1827
|
-
case 0:
|
|
1828
|
-
logger.debug('Called "load":', {
|
|
1829
|
-
id: id
|
|
1830
|
-
});
|
|
1831
|
-
|
|
1832
|
-
if (!(id === RELEASE_INJECTOR_ID)) {
|
|
1833
|
-
_context2.next = 13;
|
|
1834
|
-
break;
|
|
1835
|
-
}
|
|
1836
|
-
|
|
1837
|
-
_context2.t0 = generateGlobalInjectorCode;
|
|
1838
|
-
_context2.next = 5;
|
|
1839
|
-
return releaseNamePromise;
|
|
1840
|
-
|
|
1841
|
-
case 5:
|
|
1842
|
-
_context2.t1 = _context2.sent;
|
|
1843
|
-
_context2.t2 = internalOptions.injectReleasesMap;
|
|
1844
|
-
_context2.t3 = internalOptions.org;
|
|
1845
|
-
_context2.t4 = internalOptions.project;
|
|
1846
|
-
_context2.t5 = {
|
|
1847
|
-
release: _context2.t1,
|
|
1848
|
-
injectReleasesMap: _context2.t2,
|
|
1849
|
-
org: _context2.t3,
|
|
1850
|
-
project: _context2.t4
|
|
1851
|
-
};
|
|
1852
|
-
return _context2.abrupt("return", (0, _context2.t0)(_context2.t5));
|
|
1853
|
-
|
|
1854
|
-
case 13:
|
|
1855
|
-
return _context2.abrupt("return", undefined);
|
|
1856
|
-
|
|
1857
|
-
case 14:
|
|
1858
|
-
case "end":
|
|
1859
|
-
return _context2.stop();
|
|
1860
|
-
}
|
|
1861
|
-
}
|
|
1862
|
-
}, _callee2);
|
|
1863
|
-
}))();
|
|
1798
|
+
return undefined;
|
|
1864
1799
|
},
|
|
1865
1800
|
|
|
1866
1801
|
/**
|
|
@@ -1877,11 +1812,7 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1877
1812
|
}); // We normalize the id because vite always passes `id` as a unix style path which causes problems when a user passes
|
|
1878
1813
|
// a windows style path to `releaseInjectionTargets`
|
|
1879
1814
|
|
|
1880
|
-
var normalizedId = path.normalize(id);
|
|
1881
|
-
|
|
1882
|
-
if (normalizedId === RELEASE_INJECTOR_ID) {
|
|
1883
|
-
return false;
|
|
1884
|
-
}
|
|
1815
|
+
var normalizedId = path.normalize(id);
|
|
1885
1816
|
|
|
1886
1817
|
if (internalOptions.releaseInjectionTargets) {
|
|
1887
1818
|
// If there's an `releaseInjectionTargets` option transform (ie. inject the release varible) when the file path matches the option.
|
|
@@ -1897,13 +1828,14 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1897
1828
|
return normalizedId === normalizedEntry;
|
|
1898
1829
|
}
|
|
1899
1830
|
});
|
|
1900
|
-
} else {
|
|
1901
|
-
var isInNodeModules = normalizedId.split(path.sep).includes("node_modules");
|
|
1831
|
+
} else if (absolueEntrypointPaths.has(normalizedId)) {
|
|
1902
1832
|
var pathIsOrdinary = !normalizedId.includes("?") && !normalizedId.includes("#");
|
|
1903
1833
|
var pathHasAllowedFileEnding = ALLOWED_TRANSFORMATION_FILE_ENDINGS.some(function (allowedFileEnding) {
|
|
1904
1834
|
return normalizedId.endsWith(allowedFileEnding);
|
|
1905
1835
|
});
|
|
1906
|
-
return
|
|
1836
|
+
return pathIsOrdinary && pathHasAllowedFileEnding;
|
|
1837
|
+
} else {
|
|
1838
|
+
return false;
|
|
1907
1839
|
}
|
|
1908
1840
|
},
|
|
1909
1841
|
|
|
@@ -1916,26 +1848,57 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1916
1848
|
* @returns transformed code + source map
|
|
1917
1849
|
*/
|
|
1918
1850
|
transform: function transform(code, id) {
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1851
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
1852
|
+
var ms;
|
|
1853
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1854
|
+
while (1) {
|
|
1855
|
+
switch (_context2.prev = _context2.next) {
|
|
1856
|
+
case 0:
|
|
1857
|
+
logger.debug('Called "transform":', {
|
|
1858
|
+
id: id
|
|
1859
|
+
}); // The MagicString library allows us to generate sourcemaps for the changes we make to the user code.
|
|
1922
1860
|
|
|
1923
|
-
|
|
1924
|
-
|
|
1861
|
+
ms = new MagicString(code);
|
|
1862
|
+
_context2.t0 = ms;
|
|
1863
|
+
_context2.t1 = generateGlobalInjectorCode;
|
|
1864
|
+
_context2.next = 6;
|
|
1865
|
+
return releaseNamePromise;
|
|
1925
1866
|
|
|
1926
|
-
|
|
1867
|
+
case 6:
|
|
1868
|
+
_context2.t2 = _context2.sent;
|
|
1869
|
+
_context2.t3 = internalOptions.injectReleasesMap;
|
|
1870
|
+
_context2.t4 = internalOptions.org;
|
|
1871
|
+
_context2.t5 = internalOptions.project;
|
|
1872
|
+
_context2.t6 = {
|
|
1873
|
+
release: _context2.t2,
|
|
1874
|
+
injectReleasesMap: _context2.t3,
|
|
1875
|
+
org: _context2.t4,
|
|
1876
|
+
project: _context2.t5
|
|
1877
|
+
};
|
|
1878
|
+
_context2.t7 = (0, _context2.t1)(_context2.t6);
|
|
1927
1879
|
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1880
|
+
_context2.t0.prepend.call(_context2.t0, _context2.t7);
|
|
1881
|
+
|
|
1882
|
+
if (!(unpluginMetaContext.framework === "esbuild")) {
|
|
1883
|
+
_context2.next = 17;
|
|
1884
|
+
break;
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
return _context2.abrupt("return", ms.toString());
|
|
1888
|
+
|
|
1889
|
+
case 17:
|
|
1890
|
+
return _context2.abrupt("return", {
|
|
1891
|
+
code: ms.toString(),
|
|
1892
|
+
map: ms.generateMap()
|
|
1893
|
+
});
|
|
1894
|
+
|
|
1895
|
+
case 18:
|
|
1896
|
+
case "end":
|
|
1897
|
+
return _context2.stop();
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
}, _callee2);
|
|
1901
|
+
}))();
|
|
1939
1902
|
},
|
|
1940
1903
|
|
|
1941
1904
|
/**
|
|
@@ -2077,7 +2040,7 @@ function generateGlobalInjectorCode(_ref2) {
|
|
|
2077
2040
|
|
|
2078
2041
|
if (injectReleasesMap && project) {
|
|
2079
2042
|
var key = org ? "".concat(project, "@").concat(org) : project;
|
|
2080
|
-
code += "\n _global.SENTRY_RELEASES=_global.SENTRY_RELEASES || {};\n _global.SENTRY_RELEASES[\"".concat(key, "\"]={id:\"").concat(release, "\"}
|
|
2043
|
+
code += "\n _global.SENTRY_RELEASES=_global.SENTRY_RELEASES || {};\n _global.SENTRY_RELEASES[\"".concat(key, "\"]={id:\"").concat(release, "\"};");
|
|
2081
2044
|
}
|
|
2082
2045
|
|
|
2083
2046
|
return code;
|