@sentry/bundler-plugin-core 0.3.0 → 2.0.0-alpha.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 +77 -116
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.mjs +77 -116
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/options-mapping.d.ts +1 -1
- package/dist/types/types.d.ts +2 -11
- package/package.json +4 -4
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,6 @@ function normalizeUserOptions(userOptions) {
|
|
|
800
800
|
// the passed options are undefined.
|
|
801
801
|
authToken: userOptions.authToken,
|
|
802
802
|
// env var: `SENTRY_AUTH_TOKEN`
|
|
803
|
-
// CLI v1 (and the "old" webpack plugin) use `CUSTOM_HEADER`,
|
|
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"],
|
|
807
803
|
headers: userOptions.headers,
|
|
808
804
|
vcsRemote: userOptions.vcsRemote,
|
|
809
805
|
// env var: `SENTRY_VSC_REMOTE`
|
|
@@ -863,12 +859,12 @@ function normalizeInclude(userOptions) {
|
|
|
863
859
|
|
|
864
860
|
|
|
865
861
|
function normalizeIncludeEntry(userOptions, includeEntry) {
|
|
866
|
-
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;
|
|
867
863
|
|
|
868
|
-
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"];
|
|
869
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()`
|
|
870
866
|
|
|
871
|
-
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"];
|
|
872
868
|
var dotPrefixedExt = ext.map(function (extension) {
|
|
873
869
|
return ".".concat(extension.replace(/^\./, ""));
|
|
874
870
|
});
|
|
@@ -880,10 +876,10 @@ function normalizeIncludeEntry(userOptions, includeEntry) {
|
|
|
880
876
|
urlPrefix: (_includeEntry$urlPref = includeEntry.urlPrefix) !== null && _includeEntry$urlPref !== void 0 ? _includeEntry$urlPref : userOptions.urlPrefix,
|
|
881
877
|
urlSuffix: (_includeEntry$urlSuff = includeEntry.urlSuffix) !== null && _includeEntry$urlSuff !== void 0 ? _includeEntry$urlSuff : userOptions.urlSuffix,
|
|
882
878
|
stripPrefix: (_includeEntry$stripPr = includeEntry.stripPrefix) !== null && _includeEntry$stripPr !== void 0 ? _includeEntry$stripPr : userOptions.stripPrefix,
|
|
883
|
-
stripCommonPrefix: (
|
|
884
|
-
sourceMapReference: (
|
|
885
|
-
rewrite: (
|
|
886
|
-
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
|
|
887
883
|
};
|
|
888
884
|
}
|
|
889
885
|
/**
|
|
@@ -937,7 +933,7 @@ function makeSentryClient(dsn, allowedToSendTelemetryPromise, userProject) {
|
|
|
937
933
|
// a dashboard.
|
|
938
934
|
// Yes, this is slightly abusing the purpose of this field.
|
|
939
935
|
dist: userProject,
|
|
940
|
-
release: "0.
|
|
936
|
+
release: "2.0.0-alpha.0",
|
|
941
937
|
integrations: [],
|
|
942
938
|
tracePropagationTargets: ["sentry.io/api"],
|
|
943
939
|
stackParser: defaultStackParser,
|
|
@@ -1089,12 +1085,12 @@ function _shouldSendTelemetry() {
|
|
|
1089
1085
|
_shouldSendTelemetry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
1090
1086
|
var _cliInfo$split$, _cliInfo$split$$repla;
|
|
1091
1087
|
|
|
1092
|
-
var silent, org, project, authToken, url, vcsRemote,
|
|
1088
|
+
var silent, org, project, authToken, url, vcsRemote, headers, telemetry, dryRun, cli, cliInfo, cliInfoUrl;
|
|
1093
1089
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1094
1090
|
while (1) {
|
|
1095
1091
|
switch (_context2.prev = _context2.next) {
|
|
1096
1092
|
case 0:
|
|
1097
|
-
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
|
|
1098
1094
|
|
|
1099
1095
|
if (!(telemetry === false)) {
|
|
1100
1096
|
_context2.next = 3;
|
|
@@ -1127,7 +1123,6 @@ function _shouldSendTelemetry() {
|
|
|
1127
1123
|
project: project,
|
|
1128
1124
|
vcsRemote: vcsRemote,
|
|
1129
1125
|
silent: silent,
|
|
1130
|
-
customHeader: customHeader,
|
|
1131
1126
|
headers: headers
|
|
1132
1127
|
});
|
|
1133
1128
|
_context2.prev = 8;
|
|
@@ -1585,7 +1580,6 @@ function getSentryCli(internalOptions, logger) {
|
|
|
1585
1580
|
authToken = internalOptions.authToken,
|
|
1586
1581
|
url = internalOptions.url,
|
|
1587
1582
|
vcsRemote = internalOptions.vcsRemote,
|
|
1588
|
-
customHeader = internalOptions.customHeader,
|
|
1589
1583
|
headers = internalOptions.headers;
|
|
1590
1584
|
var cli = new SentryCli(internalOptions.configFile, {
|
|
1591
1585
|
url: url,
|
|
@@ -1594,7 +1588,6 @@ function getSentryCli(internalOptions, logger) {
|
|
|
1594
1588
|
project: project,
|
|
1595
1589
|
vcsRemote: vcsRemote,
|
|
1596
1590
|
silent: silent,
|
|
1597
|
-
customHeader: customHeader,
|
|
1598
1591
|
headers: headers
|
|
1599
1592
|
});
|
|
1600
1593
|
|
|
@@ -1647,10 +1640,6 @@ function getDryRunCLI(cli, logger) {
|
|
|
1647
1640
|
};
|
|
1648
1641
|
}
|
|
1649
1642
|
|
|
1650
|
-
// This hack is taken straight from https://rollupjs.org/guide/en/#resolveid.
|
|
1651
|
-
// This probably doesn't work for all bundlers but for rollup it does.
|
|
1652
|
-
|
|
1653
|
-
var RELEASE_INJECTOR_ID = "\0sentry-release-injector";
|
|
1654
1643
|
var ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".mjs"];
|
|
1655
1644
|
/**
|
|
1656
1645
|
* The sentry bundler plugin concerns itself with two things:
|
|
@@ -1658,17 +1647,17 @@ var ALLOWED_TRANSFORMATION_FILE_ENDINGS = [".js", ".ts", ".jsx", ".tsx", ".mjs"]
|
|
|
1658
1647
|
* - Sourcemaps upload
|
|
1659
1648
|
*
|
|
1660
1649
|
* Release injection:
|
|
1661
|
-
*
|
|
1662
|
-
*
|
|
1663
|
-
*
|
|
1664
|
-
*
|
|
1665
|
-
*
|
|
1666
|
-
* 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.
|
|
1667
1655
|
*
|
|
1668
1656
|
* Source maps upload:
|
|
1669
1657
|
*
|
|
1670
|
-
* The sentry bundler plugin will also take care of uploading source maps to Sentry. This
|
|
1671
|
-
* `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:
|
|
1672
1661
|
*
|
|
1673
1662
|
* 1. Create a new release
|
|
1674
1663
|
* 2. Delete already uploaded artifacts for this release (if `cleanArtifacts` is enabled)
|
|
@@ -1715,6 +1704,7 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1715
1704
|
});
|
|
1716
1705
|
var transaction;
|
|
1717
1706
|
var releaseInjectionSpan;
|
|
1707
|
+
var absolueEntrypointPaths = new Set();
|
|
1718
1708
|
return {
|
|
1719
1709
|
name: "sentry-plugin",
|
|
1720
1710
|
enforce: "pre",
|
|
@@ -1801,68 +1791,11 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1801
1791
|
isEntry: isEntry
|
|
1802
1792
|
});
|
|
1803
1793
|
|
|
1804
|
-
if (
|
|
1805
|
-
|
|
1806
|
-
} else {
|
|
1807
|
-
return undefined;
|
|
1794
|
+
if (isEntry) {
|
|
1795
|
+
absolueEntrypointPaths.add(path.resolve(path.normalize(id)));
|
|
1808
1796
|
}
|
|
1809
|
-
},
|
|
1810
|
-
loadInclude: function loadInclude(id) {
|
|
1811
|
-
logger.debug('Called "loadInclude":', {
|
|
1812
|
-
id: id
|
|
1813
|
-
});
|
|
1814
|
-
return id === RELEASE_INJECTOR_ID;
|
|
1815
|
-
},
|
|
1816
1797
|
|
|
1817
|
-
|
|
1818
|
-
* Responsible for "virtually" loading the "sentry-release-injector" module. "Virtual" means that the module is not
|
|
1819
|
-
* read from somewhere on disk but rather just returned via a string.
|
|
1820
|
-
*
|
|
1821
|
-
* @param id Always the absolute (fully resolved) path to the module.
|
|
1822
|
-
* @returns The global injector code when we load the "sentry-release-injector" module. Otherwise returns `undefined`.
|
|
1823
|
-
*/
|
|
1824
|
-
load: function load(id) {
|
|
1825
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
1826
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1827
|
-
while (1) {
|
|
1828
|
-
switch (_context2.prev = _context2.next) {
|
|
1829
|
-
case 0:
|
|
1830
|
-
logger.debug('Called "load":', {
|
|
1831
|
-
id: id
|
|
1832
|
-
});
|
|
1833
|
-
|
|
1834
|
-
if (!(id === RELEASE_INJECTOR_ID)) {
|
|
1835
|
-
_context2.next = 13;
|
|
1836
|
-
break;
|
|
1837
|
-
}
|
|
1838
|
-
|
|
1839
|
-
_context2.t0 = generateGlobalInjectorCode;
|
|
1840
|
-
_context2.next = 5;
|
|
1841
|
-
return releaseNamePromise;
|
|
1842
|
-
|
|
1843
|
-
case 5:
|
|
1844
|
-
_context2.t1 = _context2.sent;
|
|
1845
|
-
_context2.t2 = internalOptions.injectReleasesMap;
|
|
1846
|
-
_context2.t3 = internalOptions.org;
|
|
1847
|
-
_context2.t4 = internalOptions.project;
|
|
1848
|
-
_context2.t5 = {
|
|
1849
|
-
release: _context2.t1,
|
|
1850
|
-
injectReleasesMap: _context2.t2,
|
|
1851
|
-
org: _context2.t3,
|
|
1852
|
-
project: _context2.t4
|
|
1853
|
-
};
|
|
1854
|
-
return _context2.abrupt("return", (0, _context2.t0)(_context2.t5));
|
|
1855
|
-
|
|
1856
|
-
case 13:
|
|
1857
|
-
return _context2.abrupt("return", undefined);
|
|
1858
|
-
|
|
1859
|
-
case 14:
|
|
1860
|
-
case "end":
|
|
1861
|
-
return _context2.stop();
|
|
1862
|
-
}
|
|
1863
|
-
}
|
|
1864
|
-
}, _callee2);
|
|
1865
|
-
}))();
|
|
1798
|
+
return undefined;
|
|
1866
1799
|
},
|
|
1867
1800
|
|
|
1868
1801
|
/**
|
|
@@ -1879,11 +1812,7 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1879
1812
|
}); // We normalize the id because vite always passes `id` as a unix style path which causes problems when a user passes
|
|
1880
1813
|
// a windows style path to `releaseInjectionTargets`
|
|
1881
1814
|
|
|
1882
|
-
var normalizedId = path.normalize(id);
|
|
1883
|
-
|
|
1884
|
-
if (normalizedId === RELEASE_INJECTOR_ID) {
|
|
1885
|
-
return false;
|
|
1886
|
-
}
|
|
1815
|
+
var normalizedId = path.normalize(id);
|
|
1887
1816
|
|
|
1888
1817
|
if (internalOptions.releaseInjectionTargets) {
|
|
1889
1818
|
// If there's an `releaseInjectionTargets` option transform (ie. inject the release varible) when the file path matches the option.
|
|
@@ -1899,13 +1828,14 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1899
1828
|
return normalizedId === normalizedEntry;
|
|
1900
1829
|
}
|
|
1901
1830
|
});
|
|
1902
|
-
} else {
|
|
1903
|
-
var isInNodeModules = normalizedId.split(path.sep).includes("node_modules");
|
|
1831
|
+
} else if (absolueEntrypointPaths.has(normalizedId)) {
|
|
1904
1832
|
var pathIsOrdinary = !normalizedId.includes("?") && !normalizedId.includes("#");
|
|
1905
1833
|
var pathHasAllowedFileEnding = ALLOWED_TRANSFORMATION_FILE_ENDINGS.some(function (allowedFileEnding) {
|
|
1906
1834
|
return normalizedId.endsWith(allowedFileEnding);
|
|
1907
1835
|
});
|
|
1908
|
-
return
|
|
1836
|
+
return pathIsOrdinary && pathHasAllowedFileEnding;
|
|
1837
|
+
} else {
|
|
1838
|
+
return false;
|
|
1909
1839
|
}
|
|
1910
1840
|
},
|
|
1911
1841
|
|
|
@@ -1918,26 +1848,57 @@ var unplugin = createUnplugin(function (options, unpluginMetaContext) {
|
|
|
1918
1848
|
* @returns transformed code + source map
|
|
1919
1849
|
*/
|
|
1920
1850
|
transform: function transform(code, id) {
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
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.
|
|
1924
1860
|
|
|
1925
|
-
|
|
1926
|
-
|
|
1861
|
+
ms = new MagicString(code);
|
|
1862
|
+
_context2.t0 = ms;
|
|
1863
|
+
_context2.t1 = generateGlobalInjectorCode;
|
|
1864
|
+
_context2.next = 6;
|
|
1865
|
+
return releaseNamePromise;
|
|
1927
1866
|
|
|
1928
|
-
|
|
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);
|
|
1929
1879
|
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
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
|
+
}))();
|
|
1941
1902
|
},
|
|
1942
1903
|
|
|
1943
1904
|
/**
|
|
@@ -2079,7 +2040,7 @@ function generateGlobalInjectorCode(_ref2) {
|
|
|
2079
2040
|
|
|
2080
2041
|
if (injectReleasesMap && project) {
|
|
2081
2042
|
var key = org ? "".concat(project, "@").concat(org) : project;
|
|
2082
|
-
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, "\"};");
|
|
2083
2044
|
}
|
|
2084
2045
|
|
|
2085
2046
|
return code;
|