@sentry/bundler-plugin-core 4.6.1 → 4.7.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 +153 -128
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.mjs +153 -126
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/build-plugin-manager.d.ts.map +1 -1
- package/dist/types/index.d.ts +9 -10
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/utils.d.ts +18 -0
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/cjs/index.js
CHANGED
|
@@ -8036,6 +8036,48 @@ function getProjects(project) {
|
|
|
8036
8036
|
return undefined;
|
|
8037
8037
|
}
|
|
8038
8038
|
|
|
8039
|
+
/**
|
|
8040
|
+
* Inlined functionality from @sentry/cli helper code to add `--ignore` options.
|
|
8041
|
+
*
|
|
8042
|
+
* Temporary workaround until we expose a function for injecting debug IDs. Currently, we directly call `execute` with CLI args to inject them.
|
|
8043
|
+
*/
|
|
8044
|
+
function serializeIgnoreOptions(ignoreValue) {
|
|
8045
|
+
var DEFAULT_IGNORE = ["node_modules"];
|
|
8046
|
+
var ignoreOptions = Array.isArray(ignoreValue) ? ignoreValue : typeof ignoreValue === "string" ? [ignoreValue] : DEFAULT_IGNORE;
|
|
8047
|
+
return ignoreOptions.reduce(function (acc, value) {
|
|
8048
|
+
return acc.concat(["--ignore", String(value)]);
|
|
8049
|
+
}, []);
|
|
8050
|
+
}
|
|
8051
|
+
|
|
8052
|
+
/**
|
|
8053
|
+
* Checks if a chunk contains only import/export statements and no substantial code.
|
|
8054
|
+
*
|
|
8055
|
+
* In Vite MPA (multi-page application) mode, HTML entry points create "facade" chunks
|
|
8056
|
+
* that only contain import statements to load shared modules. These should not have
|
|
8057
|
+
* Sentry code injected. However, in SPA mode, the main bundle also has an HTML facade
|
|
8058
|
+
* but contains substantial application code that SHOULD have debug IDs injected.
|
|
8059
|
+
*
|
|
8060
|
+
* @ref https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/829
|
|
8061
|
+
* @ref https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/839
|
|
8062
|
+
*/
|
|
8063
|
+
function containsOnlyImports(code) {
|
|
8064
|
+
var codeWithoutImports = code
|
|
8065
|
+
// Remove side effect imports: import '/path'; or import "./path";
|
|
8066
|
+
// Using explicit negated character classes to avoid polynomial backtracking
|
|
8067
|
+
.replace(/^\s*import\s+(?:'[^'\n]*'|"[^"\n]*"|`[^`\n]*`)[\s;]*$/gm, "")
|
|
8068
|
+
// Remove named/default imports: import x from '/path'; import { x } from '/path';
|
|
8069
|
+
.replace(/^\s*import\b[^'"`\n]*\bfrom\s+(?:'[^'\n]*'|"[^"\n]*"|`[^`\n]*`)[\s;]*$/gm, "")
|
|
8070
|
+
// Remove re-exports: export * from '/path'; export { x } from '/path';
|
|
8071
|
+
.replace(/^\s*export\b[^'"`\n]*\bfrom\s+(?:'[^'\n]*'|"[^"\n]*"|`[^`\n]*`)[\s;]*$/gm, "")
|
|
8072
|
+
// Remove block comments
|
|
8073
|
+
.replace(/\/\*[\s\S]*?\*\//g, "")
|
|
8074
|
+
// Remove line comments
|
|
8075
|
+
.replace(/\/\/.*$/gm, "")
|
|
8076
|
+
// Remove "use strict" directives
|
|
8077
|
+
.replace(/["']use strict["']\s*;?/g, "").trim();
|
|
8078
|
+
return codeWithoutImports.length === 0;
|
|
8079
|
+
}
|
|
8080
|
+
|
|
8039
8081
|
var SENTRY_SAAS_URL = "https://sentry.io";
|
|
8040
8082
|
function normalizeUserOptions(userOptions) {
|
|
8041
8083
|
var _userOptions$org, _userOptions$project, _process$env$SENTRY_P, _userOptions$authToke, _ref, _userOptions$url, _userOptions$debug, _userOptions$silent, _userOptions$telemetr, _userOptions$disable, _ref2, _userOptions$release$, _userOptions$release, _userOptions$release$2, _userOptions$release2, _userOptions$release$3, _userOptions$release3, _userOptions$release$4, _userOptions$release4, _ref3, _userOptions$release$5, _userOptions$release5, _userOptions$release6, _userOptions$_metaOpt, _userOptions$_metaOpt2, _userOptions$_experim;
|
|
@@ -8336,7 +8378,7 @@ function createSentryInstance(options, shouldSendTelemetry, buildTool) {
|
|
|
8336
8378
|
dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
|
|
8337
8379
|
tracesSampleRate: 1,
|
|
8338
8380
|
sampleRate: 1,
|
|
8339
|
-
release: "4.
|
|
8381
|
+
release: "4.7.0",
|
|
8340
8382
|
integrations: [],
|
|
8341
8383
|
tracePropagationTargets: ["sentry.io/api"],
|
|
8342
8384
|
stackParser: stackParser,
|
|
@@ -8945,7 +8987,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
|
|
|
8945
8987
|
});
|
|
8946
8988
|
|
|
8947
8989
|
// Set the User-Agent that Sentry CLI will use when interacting with Sentry
|
|
8948
|
-
process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.
|
|
8990
|
+
process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.7.0");
|
|
8949
8991
|
|
|
8950
8992
|
// Propagate debug flag to Sentry CLI via environment variable
|
|
8951
8993
|
// Only set if not already defined to respect user's explicit configuration
|
|
@@ -9313,14 +9355,14 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
|
|
|
9313
9355
|
scope: sentryScope,
|
|
9314
9356
|
forceTransaction: true
|
|
9315
9357
|
}, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
9316
|
-
var _options$
|
|
9358
|
+
var _options$sourcemaps, cliInstance;
|
|
9317
9359
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
9318
9360
|
while (1) switch (_context8.prev = _context8.next) {
|
|
9319
9361
|
case 0:
|
|
9320
9362
|
_context8.prev = 0;
|
|
9321
9363
|
cliInstance = createCliInstance(options);
|
|
9322
9364
|
_context8.next = 4;
|
|
9323
|
-
return cliInstance.execute(["sourcemaps", "inject"].concat(_toConsumableArray(
|
|
9365
|
+
return cliInstance.execute(["sourcemaps", "inject"].concat(_toConsumableArray(serializeIgnoreOptions((_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.ignore)), _toConsumableArray(buildArtifactPaths)), options.debug ? "rejectOnError" : false);
|
|
9324
9366
|
case 4:
|
|
9325
9367
|
_context8.next = 10;
|
|
9326
9368
|
break;
|
|
@@ -9360,7 +9402,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
|
|
|
9360
9402
|
*/
|
|
9361
9403
|
uploadSourcemaps: function uploadSourcemaps(buildArtifactPaths, opts) {
|
|
9362
9404
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
9363
|
-
var _options$
|
|
9405
|
+
var _options$sourcemaps2;
|
|
9364
9406
|
var assets;
|
|
9365
9407
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
9366
9408
|
while (1) switch (_context19.prev = _context19.next) {
|
|
@@ -9372,7 +9414,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
|
|
|
9372
9414
|
return _context19.abrupt("return");
|
|
9373
9415
|
case 2:
|
|
9374
9416
|
// Early exit if assets is explicitly set to an empty array
|
|
9375
|
-
assets = (_options$
|
|
9417
|
+
assets = (_options$sourcemaps2 = options.sourcemaps) === null || _options$sourcemaps2 === void 0 ? void 0 : _options$sourcemaps2.assets;
|
|
9376
9418
|
if (!(Array.isArray(assets) && assets.length === 0)) {
|
|
9377
9419
|
_context19.next = 6;
|
|
9378
9420
|
break;
|
|
@@ -9389,7 +9431,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
|
|
|
9389
9431
|
forceTransaction: true
|
|
9390
9432
|
}, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
9391
9433
|
var _opts$prepareArtifact;
|
|
9392
|
-
var shouldPrepare, folderToCleanUp, freeUploadDependencyOnBuildArtifacts, _options$
|
|
9434
|
+
var shouldPrepare, folderToCleanUp, freeUploadDependencyOnBuildArtifacts, _options$sourcemaps3, _options$sourcemaps4, _options$sourcemaps5, _options$sourcemaps6, pathsToUpload, ignorePaths, globAssets, globResult, debugIdChunkFilePaths, tmpUploadFolder, _process$env2;
|
|
9393
9435
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
9394
9436
|
while (1) switch (_context18.prev = _context18.next) {
|
|
9395
9437
|
case 0:
|
|
@@ -9412,7 +9454,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
|
|
|
9412
9454
|
// Use original paths e.g. like ['.next/server'] directly –> preferred way when no globbing is done
|
|
9413
9455
|
pathsToUpload = buildArtifactPaths;
|
|
9414
9456
|
}
|
|
9415
|
-
ignorePaths = (_options$
|
|
9457
|
+
ignorePaths = (_options$sourcemaps3 = options.sourcemaps) !== null && _options$sourcemaps3 !== void 0 && _options$sourcemaps3.ignore ? Array.isArray((_options$sourcemaps4 = options.sourcemaps) === null || _options$sourcemaps4 === void 0 ? void 0 : _options$sourcemaps4.ignore) ? (_options$sourcemaps5 = options.sourcemaps) === null || _options$sourcemaps5 === void 0 ? void 0 : _options$sourcemaps5.ignore : [(_options$sourcemaps6 = options.sourcemaps) === null || _options$sourcemaps6 === void 0 ? void 0 : _options$sourcemaps6.ignore] : [];
|
|
9416
9458
|
_context18.next = 8;
|
|
9417
9459
|
return startSpan({
|
|
9418
9460
|
name: "upload",
|
|
@@ -9459,7 +9501,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
|
|
|
9459
9501
|
name: "glob",
|
|
9460
9502
|
scope: sentryScope
|
|
9461
9503
|
}, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
9462
|
-
var _options$
|
|
9504
|
+
var _options$sourcemaps7;
|
|
9463
9505
|
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
9464
9506
|
while (1) switch (_context11.prev = _context11.next) {
|
|
9465
9507
|
case 0:
|
|
@@ -9468,7 +9510,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
|
|
|
9468
9510
|
absolute: true,
|
|
9469
9511
|
nodir: true,
|
|
9470
9512
|
// We need individual files for preparation
|
|
9471
|
-
ignore: (_options$
|
|
9513
|
+
ignore: (_options$sourcemaps7 = options.sourcemaps) === null || _options$sourcemaps7 === void 0 ? void 0 : _options$sourcemaps7.ignore
|
|
9472
9514
|
});
|
|
9473
9515
|
case 2:
|
|
9474
9516
|
return _context11.abrupt("return", _context11.sent);
|
|
@@ -9538,12 +9580,12 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
|
|
|
9538
9580
|
// instead we do it with a maximum of 16 concurrent workers
|
|
9539
9581
|
preparationTasks = debugIdChunkFilePaths.map(function (chunkFilePath, chunkIndex) {
|
|
9540
9582
|
return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
9541
|
-
var _options$sourcemaps$r, _options$
|
|
9583
|
+
var _options$sourcemaps$r, _options$sourcemaps8, _options$sourcemaps9;
|
|
9542
9584
|
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
9543
9585
|
while (1) switch (_context13.prev = _context13.next) {
|
|
9544
9586
|
case 0:
|
|
9545
9587
|
_context13.next = 2;
|
|
9546
|
-
return prepareBundleForDebugIdUpload(chunkFilePath, tmpUploadFolder, chunkIndex, logger, (_options$sourcemaps$r = (_options$
|
|
9588
|
+
return prepareBundleForDebugIdUpload(chunkFilePath, tmpUploadFolder, chunkIndex, logger, (_options$sourcemaps$r = (_options$sourcemaps8 = options.sourcemaps) === null || _options$sourcemaps8 === void 0 ? void 0 : _options$sourcemaps8.rewriteSources) !== null && _options$sourcemaps$r !== void 0 ? _options$sourcemaps$r : defaultRewriteSourcesHook, (_options$sourcemaps9 = options.sourcemaps) === null || _options$sourcemaps9 === void 0 ? void 0 : _options$sourcemaps9.resolveSourceMap);
|
|
9547
9589
|
case 2:
|
|
9548
9590
|
case "end":
|
|
9549
9591
|
return _context13.stop();
|
|
@@ -9706,13 +9748,13 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
|
|
|
9706
9748
|
*/
|
|
9707
9749
|
deleteArtifacts: function deleteArtifacts() {
|
|
9708
9750
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
9709
|
-
var _options$
|
|
9751
|
+
var _options$sourcemaps10, filesToDelete, filePathsToDelete;
|
|
9710
9752
|
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
9711
9753
|
while (1) switch (_context20.prev = _context20.next) {
|
|
9712
9754
|
case 0:
|
|
9713
9755
|
_context20.prev = 0;
|
|
9714
9756
|
_context20.next = 3;
|
|
9715
|
-
return (_options$
|
|
9757
|
+
return (_options$sourcemaps10 = options.sourcemaps) === null || _options$sourcemaps10 === void 0 ? void 0 : _options$sourcemaps10.filesToDeleteAfterUpload;
|
|
9716
9758
|
case 3:
|
|
9717
9759
|
filesToDelete = _context20.sent;
|
|
9718
9760
|
if (!(filesToDelete !== undefined)) {
|
|
@@ -9766,8 +9808,8 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
|
|
|
9766
9808
|
};
|
|
9767
9809
|
}
|
|
9768
9810
|
function canUploadSourceMaps(options, logger, isDevMode) {
|
|
9769
|
-
var _options$
|
|
9770
|
-
if ((_options$
|
|
9811
|
+
var _options$sourcemaps11, _getProjects3;
|
|
9812
|
+
if ((_options$sourcemaps11 = options.sourcemaps) !== null && _options$sourcemaps11 !== void 0 && _options$sourcemaps11.disable) {
|
|
9771
9813
|
logger.debug("Source map upload was disabled. Will not upload sourcemaps using debug ID process.");
|
|
9772
9814
|
return false;
|
|
9773
9815
|
}
|
|
@@ -9794,14 +9836,12 @@ function canUploadSourceMaps(options, logger, isDevMode) {
|
|
|
9794
9836
|
* Creates an unplugin instance used to create Sentry plugins for Vite, Rollup, esbuild, and Webpack.
|
|
9795
9837
|
*/
|
|
9796
9838
|
function sentryUnpluginFactory(_ref) {
|
|
9797
|
-
var
|
|
9839
|
+
var injectionPlugin = _ref.injectionPlugin,
|
|
9798
9840
|
componentNameAnnotatePlugin = _ref.componentNameAnnotatePlugin,
|
|
9799
|
-
moduleMetadataInjectionPlugin = _ref.moduleMetadataInjectionPlugin,
|
|
9800
|
-
debugIdInjectionPlugin = _ref.debugIdInjectionPlugin,
|
|
9801
9841
|
debugIdUploadPlugin = _ref.debugIdUploadPlugin,
|
|
9802
9842
|
bundleSizeOptimizationsPlugin = _ref.bundleSizeOptimizationsPlugin;
|
|
9803
9843
|
return unplugin.createUnplugin(function () {
|
|
9804
|
-
var _userOptions$_metaOpt, _userOptions$_metaOpt2, _options$sourcemaps;
|
|
9844
|
+
var _userOptions$_metaOpt, _userOptions$_metaOpt2, _options$sourcemaps, _options$sourcemaps3;
|
|
9805
9845
|
var userOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
9806
9846
|
var unpluginMetaContext = arguments.length > 1 ? arguments[1] : undefined;
|
|
9807
9847
|
var sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {
|
|
@@ -9838,20 +9878,33 @@ function sentryUnpluginFactory(_ref) {
|
|
|
9838
9878
|
if (Object.keys(bundleSizeOptimizationReplacementValues).length > 0) {
|
|
9839
9879
|
plugins.push(bundleSizeOptimizationsPlugin(bundleSizeOptimizationReplacementValues));
|
|
9840
9880
|
}
|
|
9881
|
+
var injectionCode = "";
|
|
9841
9882
|
if (!options.release.inject) {
|
|
9842
9883
|
logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
|
|
9843
9884
|
} else if (!options.release.name) {
|
|
9844
9885
|
logger.debug("No release name provided. Will not inject release. Please set the `release.name` option to identify your release.");
|
|
9845
9886
|
} else {
|
|
9846
|
-
var
|
|
9887
|
+
var _code = generateGlobalInjectorCode({
|
|
9847
9888
|
release: options.release.name,
|
|
9848
9889
|
injectBuildInformation: options._experiments.injectBuildInformation || false
|
|
9849
9890
|
});
|
|
9850
|
-
|
|
9891
|
+
if (typeof injectionPlugin !== "function") {
|
|
9892
|
+
plugins.push(injectionPlugin.releaseInjectionPlugin(_code));
|
|
9893
|
+
} else {
|
|
9894
|
+
injectionCode += _code;
|
|
9895
|
+
}
|
|
9851
9896
|
}
|
|
9852
9897
|
if (Object.keys(sentryBuildPluginManager.bundleMetadata).length > 0) {
|
|
9853
|
-
var
|
|
9854
|
-
|
|
9898
|
+
var _code2 = generateModuleMetadataInjectorCode(sentryBuildPluginManager.bundleMetadata);
|
|
9899
|
+
if (typeof injectionPlugin !== "function") {
|
|
9900
|
+
plugins.push(injectionPlugin.moduleMetadataInjectionPlugin(_code2));
|
|
9901
|
+
} else {
|
|
9902
|
+
injectionCode += _code2;
|
|
9903
|
+
}
|
|
9904
|
+
}
|
|
9905
|
+
if (typeof injectionPlugin === "function" && (injectionCode !== "" || ((_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.disable) !== true)) {
|
|
9906
|
+
var _options$sourcemaps2;
|
|
9907
|
+
plugins.push(injectionPlugin(injectionCode, ((_options$sourcemaps2 = options.sourcemaps) === null || _options$sourcemaps2 === void 0 ? void 0 : _options$sourcemaps2.disable) !== true, logger));
|
|
9855
9908
|
}
|
|
9856
9909
|
|
|
9857
9910
|
// Add plugin to create and finalize releases, and also take care of adding commits and legacy sourcemaps
|
|
@@ -9878,10 +9931,12 @@ function sentryUnpluginFactory(_ref) {
|
|
|
9878
9931
|
}))();
|
|
9879
9932
|
}
|
|
9880
9933
|
});
|
|
9881
|
-
if (((_options$
|
|
9882
|
-
var _options$
|
|
9883
|
-
|
|
9884
|
-
|
|
9934
|
+
if (((_options$sourcemaps3 = options.sourcemaps) === null || _options$sourcemaps3 === void 0 ? void 0 : _options$sourcemaps3.disable) !== true) {
|
|
9935
|
+
var _options$sourcemaps4;
|
|
9936
|
+
if (typeof injectionPlugin !== "function") {
|
|
9937
|
+
plugins.push(injectionPlugin.debugIdInjectionPlugin(logger));
|
|
9938
|
+
}
|
|
9939
|
+
if (((_options$sourcemaps4 = options.sourcemaps) === null || _options$sourcemaps4 === void 0 ? void 0 : _options$sourcemaps4.disable) !== "disable-upload") {
|
|
9885
9940
|
// This option is only strongly typed for the webpack plugin, where it is used. It has no effect on other plugins
|
|
9886
9941
|
var _webpack_forceExitOnBuildComplete = typeof options._experiments["forceExitOnBuildCompletion"] === "boolean" ? options._experiments["forceExitOnBuildCompletion"] : undefined;
|
|
9887
9942
|
plugins.push(debugIdUploadPlugin(createDebugIdUploadFunction({
|
|
@@ -9942,42 +9997,43 @@ var COMMENT_USE_STRICT_REGEX =
|
|
|
9942
9997
|
* about type mismatches
|
|
9943
9998
|
*/
|
|
9944
9999
|
|
|
9945
|
-
|
|
9946
|
-
|
|
9947
|
-
|
|
9948
|
-
|
|
9949
|
-
|
|
9950
|
-
|
|
9951
|
-
|
|
9952
|
-
|
|
9953
|
-
|
|
9954
|
-
var ms = new MagicString__default["default"](code, {
|
|
9955
|
-
filename: chunk.fileName
|
|
9956
|
-
});
|
|
9957
|
-
var match = (_code$match = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match === void 0 ? void 0 : _code$match[0];
|
|
9958
|
-
if (match) {
|
|
9959
|
-
// Add injected code after any comments or "use strict" at the beginning of the bundle.
|
|
9960
|
-
ms.appendLeft(match.length, injectionCode);
|
|
9961
|
-
} else {
|
|
9962
|
-
// ms.replace() doesn't work when there is an empty string match (which happens if
|
|
9963
|
-
// there is neither, a comment, nor a "use strict" at the top of the chunk) so we
|
|
9964
|
-
// need this special case here.
|
|
9965
|
-
ms.prepend(injectionCode);
|
|
9966
|
-
}
|
|
9967
|
-
return {
|
|
9968
|
-
code: ms.toString(),
|
|
9969
|
-
map: ms.generateMap({
|
|
9970
|
-
file: chunk.fileName,
|
|
9971
|
-
hires: "boundary"
|
|
9972
|
-
})
|
|
9973
|
-
};
|
|
9974
|
-
} else {
|
|
9975
|
-
return null; // returning null means not modifying the chunk at all
|
|
9976
|
-
}
|
|
9977
|
-
}
|
|
9978
|
-
};
|
|
10000
|
+
/**
|
|
10001
|
+
* Checks if a file is a JavaScript file based on its extension.
|
|
10002
|
+
* Handles query strings and hashes in the filename.
|
|
10003
|
+
*/
|
|
10004
|
+
function isJsFile(fileName) {
|
|
10005
|
+
var cleanFileName = stripQueryAndHashFromPath(fileName);
|
|
10006
|
+
return [".js", ".mjs", ".cjs"].some(function (ext) {
|
|
10007
|
+
return cleanFileName.endsWith(ext);
|
|
10008
|
+
});
|
|
9979
10009
|
}
|
|
9980
10010
|
|
|
10011
|
+
/**
|
|
10012
|
+
* Checks if a chunk should be skipped for code injection
|
|
10013
|
+
*
|
|
10014
|
+
* This is necessary to handle Vite's MPA (multi-page application) mode where
|
|
10015
|
+
* HTML entry points create "facade" chunks that should not contain injected code.
|
|
10016
|
+
* See: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/829
|
|
10017
|
+
*
|
|
10018
|
+
* However, in SPA mode, the main bundle also has an HTML facade but contains
|
|
10019
|
+
* substantial application code. We should NOT skip injection for these bundles.
|
|
10020
|
+
*
|
|
10021
|
+
* @param code - The chunk's code content
|
|
10022
|
+
* @param facadeModuleId - The facade module ID (if any) - HTML files create facade chunks
|
|
10023
|
+
* @returns true if the chunk should be skipped
|
|
10024
|
+
*/
|
|
10025
|
+
function shouldSkipCodeInjection(code, facadeModuleId) {
|
|
10026
|
+
// Skip empty chunks - these are placeholder chunks that should be optimized away
|
|
10027
|
+
if (code.trim().length === 0) {
|
|
10028
|
+
return true;
|
|
10029
|
+
}
|
|
10030
|
+
|
|
10031
|
+
// For HTML facade chunks, only skip if they contain only import statements
|
|
10032
|
+
if (facadeModuleId && stripQueryAndHashFromPath(facadeModuleId).endsWith(".html")) {
|
|
10033
|
+
return containsOnlyImports(code);
|
|
10034
|
+
}
|
|
10035
|
+
return false;
|
|
10036
|
+
}
|
|
9981
10037
|
function createRollupBundleSizeOptimizationHooks(replacementValues) {
|
|
9982
10038
|
return {
|
|
9983
10039
|
transform: function transform(code) {
|
|
@@ -9985,80 +10041,51 @@ function createRollupBundleSizeOptimizationHooks(replacementValues) {
|
|
|
9985
10041
|
}
|
|
9986
10042
|
};
|
|
9987
10043
|
}
|
|
9988
|
-
function
|
|
10044
|
+
function createRollupInjectionHooks(injectionCode, debugIds) {
|
|
9989
10045
|
return {
|
|
9990
10046
|
renderChunk: function renderChunk(code, chunk) {
|
|
9991
|
-
|
|
9992
|
-
|
|
9993
|
-
[".js", ".mjs", ".cjs"].some(function (ending) {
|
|
9994
|
-
return stripQueryAndHashFromPath(chunk.fileName).endsWith(ending);
|
|
9995
|
-
})) {
|
|
9996
|
-
var _code$match2;
|
|
9997
|
-
var debugId = stringToUUID(code); // generate a deterministic debug ID
|
|
9998
|
-
var codeToInject = getDebugIdSnippet(debugId);
|
|
9999
|
-
var ms = new MagicString__default["default"](code, {
|
|
10000
|
-
filename: chunk.fileName
|
|
10001
|
-
});
|
|
10002
|
-
var match = (_code$match2 = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match2 === void 0 ? void 0 : _code$match2[0];
|
|
10003
|
-
if (match) {
|
|
10004
|
-
// Add injected code after any comments or "use strict" at the beginning of the bundle.
|
|
10005
|
-
ms.appendLeft(match.length, codeToInject);
|
|
10006
|
-
} else {
|
|
10007
|
-
// ms.replace() doesn't work when there is an empty string match (which happens if
|
|
10008
|
-
// there is neither, a comment, nor a "use strict" at the top of the chunk) so we
|
|
10009
|
-
// need this special case here.
|
|
10010
|
-
ms.prepend(codeToInject);
|
|
10011
|
-
}
|
|
10012
|
-
return {
|
|
10013
|
-
code: ms.toString(),
|
|
10014
|
-
map: ms.generateMap({
|
|
10015
|
-
file: chunk.fileName,
|
|
10016
|
-
hires: "boundary"
|
|
10017
|
-
})
|
|
10018
|
-
};
|
|
10019
|
-
} else {
|
|
10047
|
+
var _code$match;
|
|
10048
|
+
if (!isJsFile(chunk.fileName)) {
|
|
10020
10049
|
return null; // returning null means not modifying the chunk at all
|
|
10021
10050
|
}
|
|
10022
|
-
}
|
|
10023
|
-
};
|
|
10024
|
-
}
|
|
10025
10051
|
|
|
10026
|
-
|
|
10027
|
-
|
|
10028
|
-
|
|
10029
|
-
|
|
10030
|
-
|
|
10031
|
-
|
|
10032
|
-
|
|
10033
|
-
|
|
10034
|
-
var
|
|
10035
|
-
|
|
10036
|
-
|
|
10037
|
-
|
|
10038
|
-
var match = (_code$match3 = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match3 === void 0 ? void 0 : _code$match3[0];
|
|
10039
|
-
if (match) {
|
|
10040
|
-
// Add injected code after any comments or "use strict" at the beginning of the bundle.
|
|
10041
|
-
ms.appendLeft(match.length, injectionCode);
|
|
10042
|
-
} else {
|
|
10043
|
-
// ms.replace() doesn't work when there is an empty string match (which happens if
|
|
10044
|
-
// there is neither, a comment, nor a "use strict" at the top of the chunk) so we
|
|
10045
|
-
// need this special case here.
|
|
10046
|
-
ms.prepend(injectionCode);
|
|
10052
|
+
// Skip empty chunks and HTML facade chunks (Vite MPA)
|
|
10053
|
+
if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {
|
|
10054
|
+
return null;
|
|
10055
|
+
}
|
|
10056
|
+
var codeToInject = injectionCode;
|
|
10057
|
+
if (debugIds) {
|
|
10058
|
+
// Check if a debug ID has already been injected to avoid duplicate injection (e.g. by another plugin or Sentry CLI)
|
|
10059
|
+
var chunkStartSnippet = code.slice(0, 6000);
|
|
10060
|
+
var chunkEndSnippet = code.slice(-500);
|
|
10061
|
+
if (!(chunkStartSnippet.includes("_sentryDebugIdIdentifier") || chunkEndSnippet.includes("//# debugId="))) {
|
|
10062
|
+
var debugId = stringToUUID(code); // generate a deterministic debug ID
|
|
10063
|
+
codeToInject += getDebugIdSnippet(debugId);
|
|
10047
10064
|
}
|
|
10048
|
-
|
|
10049
|
-
|
|
10050
|
-
|
|
10051
|
-
|
|
10052
|
-
|
|
10053
|
-
|
|
10054
|
-
|
|
10065
|
+
}
|
|
10066
|
+
var ms = new MagicString__default["default"](code, {
|
|
10067
|
+
filename: chunk.fileName
|
|
10068
|
+
});
|
|
10069
|
+
var match = (_code$match = code.match(COMMENT_USE_STRICT_REGEX)) === null || _code$match === void 0 ? void 0 : _code$match[0];
|
|
10070
|
+
if (match) {
|
|
10071
|
+
// Add injected code after any comments or "use strict" at the beginning of the bundle.
|
|
10072
|
+
ms.appendLeft(match.length, codeToInject);
|
|
10055
10073
|
} else {
|
|
10056
|
-
|
|
10074
|
+
// ms.replace() doesn't work when there is an empty string match (which happens if
|
|
10075
|
+
// there is neither, a comment, nor a "use strict" at the top of the chunk) so we
|
|
10076
|
+
// need this special case here.
|
|
10077
|
+
ms.prepend(codeToInject);
|
|
10057
10078
|
}
|
|
10079
|
+
return {
|
|
10080
|
+
code: ms.toString(),
|
|
10081
|
+
map: ms.generateMap({
|
|
10082
|
+
file: chunk.fileName,
|
|
10083
|
+
hires: "boundary"
|
|
10084
|
+
})
|
|
10085
|
+
};
|
|
10058
10086
|
}
|
|
10059
10087
|
};
|
|
10060
10088
|
}
|
|
10061
|
-
|
|
10062
10089
|
function createRollupDebugIdUploadHooks(upload, _logger, createDependencyOnBuildArtifacts) {
|
|
10063
10090
|
var freeGlobalDependencyOnDebugIdSourcemapArtifacts = createDependencyOnBuildArtifacts();
|
|
10064
10091
|
return {
|
|
@@ -10196,10 +10223,8 @@ function getDebugIdSnippet(debugId) {
|
|
|
10196
10223
|
|
|
10197
10224
|
exports.createComponentNameAnnotateHooks = createComponentNameAnnotateHooks;
|
|
10198
10225
|
exports.createRollupBundleSizeOptimizationHooks = createRollupBundleSizeOptimizationHooks;
|
|
10199
|
-
exports.createRollupDebugIdInjectionHooks = createRollupDebugIdInjectionHooks;
|
|
10200
10226
|
exports.createRollupDebugIdUploadHooks = createRollupDebugIdUploadHooks;
|
|
10201
|
-
exports.
|
|
10202
|
-
exports.createRollupReleaseInjectionHooks = createRollupReleaseInjectionHooks;
|
|
10227
|
+
exports.createRollupInjectionHooks = createRollupInjectionHooks;
|
|
10203
10228
|
exports.createSentryBuildPluginManager = createSentryBuildPluginManager;
|
|
10204
10229
|
exports.getDebugIdSnippet = getDebugIdSnippet;
|
|
10205
10230
|
exports.replaceBooleanFlagsInCode = replaceBooleanFlagsInCode;
|