@sentry/bundler-plugin-core 0.5.1 → 0.6.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 +96 -39
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.mjs +96 -39
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/debug-id.d.ts +1 -1
- package/dist/types/types.d.ts +1 -1
- package/package.json +5 -4
package/dist/cjs/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var crypto = require('crypto');
|
|
|
14
14
|
require('@sentry/tracing');
|
|
15
15
|
var util = require('util');
|
|
16
16
|
var glob = require('glob');
|
|
17
|
+
var webpackSources = require('webpack-sources');
|
|
17
18
|
|
|
18
19
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
20
|
|
|
@@ -1121,7 +1122,7 @@ function makeSentryClient(dsn, allowedToSendTelemetryPromise, userProject) {
|
|
|
1121
1122
|
// a dashboard.
|
|
1122
1123
|
// Yes, this is slightly abusing the purpose of this field.
|
|
1123
1124
|
dist: userProject,
|
|
1124
|
-
release: "0.
|
|
1125
|
+
release: "0.6.0",
|
|
1125
1126
|
integrations: [],
|
|
1126
1127
|
tracePropagationTargets: ["sentry.io/api"],
|
|
1127
1128
|
stackParser: node.defaultStackParser,
|
|
@@ -1901,12 +1902,14 @@ function getDryRunCLI(cli, logger) {
|
|
|
1901
1902
|
}
|
|
1902
1903
|
|
|
1903
1904
|
var DEBUG_ID_INJECTOR_SNIPPET = ';!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]="__SENTRY_DEBUG_ID__",e._sentryDebugIdIdentifier="sentry-dbid-__SENTRY_DEBUG_ID__")}catch(e){}}();';
|
|
1904
|
-
function injectDebugIdSnippetIntoChunk(code) {
|
|
1905
|
+
function injectDebugIdSnippetIntoChunk(code, filename) {
|
|
1905
1906
|
var _code$match;
|
|
1906
1907
|
|
|
1907
1908
|
var debugId = stringToUUID(code); // generate a deterministic debug ID
|
|
1908
1909
|
|
|
1909
|
-
var ms = new MagicString__default["default"](code
|
|
1910
|
+
var ms = new MagicString__default["default"](code, {
|
|
1911
|
+
filename: filename
|
|
1912
|
+
});
|
|
1910
1913
|
var codeToInject = DEBUG_ID_INJECTOR_SNIPPET.replace(/__SENTRY_DEBUG_ID__/g, debugId); // We need to be careful not to inject the snippet before any `"use strict";`s.
|
|
1911
1914
|
// As an additional complication `"use strict";`s may come after any number of comments.
|
|
1912
1915
|
|
|
@@ -2313,6 +2316,10 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
2313
2316
|
id: id
|
|
2314
2317
|
});
|
|
2315
2318
|
|
|
2319
|
+
if (id.includes("sentry-release-injection-file")) {
|
|
2320
|
+
return true;
|
|
2321
|
+
}
|
|
2322
|
+
|
|
2316
2323
|
if (id.match(/\\node_modules\\|\/node_modules\//)) {
|
|
2317
2324
|
return false; // never transform 3rd party modules
|
|
2318
2325
|
} // We normalize the id because vite always passes `id` as a unix style path which causes problems when a user passes
|
|
@@ -2321,10 +2328,6 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
2321
2328
|
|
|
2322
2329
|
var normalizedId = path__default["default"].normalize(id);
|
|
2323
2330
|
|
|
2324
|
-
if (id.includes("sentry-release-injection-file")) {
|
|
2325
|
-
return true;
|
|
2326
|
-
}
|
|
2327
|
-
|
|
2328
2331
|
if (internalOptions.releaseInjectionTargets) {
|
|
2329
2332
|
// If there's an `releaseInjectionTargets` option transform (ie. inject the release varible) when the file path matches the option.
|
|
2330
2333
|
if (typeof internalOptions.releaseInjectionTargets === "function") {
|
|
@@ -2476,24 +2479,29 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
2476
2479
|
releaseName = _context4.sent;
|
|
2477
2480
|
_context4.prev = 8;
|
|
2478
2481
|
|
|
2482
|
+
if (unpluginMetaContext.watchMode) {
|
|
2483
|
+
_context4.next = 34;
|
|
2484
|
+
break;
|
|
2485
|
+
}
|
|
2486
|
+
|
|
2479
2487
|
if (!internalOptions._experiments.debugIdUpload) {
|
|
2480
|
-
_context4.next =
|
|
2488
|
+
_context4.next = 22;
|
|
2481
2489
|
break;
|
|
2482
2490
|
}
|
|
2483
2491
|
|
|
2484
|
-
_context4.next =
|
|
2492
|
+
_context4.next = 13;
|
|
2485
2493
|
return glob.glob(internalOptions._experiments.debugIdUpload.include, {
|
|
2486
2494
|
absolute: true,
|
|
2487
2495
|
nodir: true,
|
|
2488
2496
|
ignore: internalOptions._experiments.debugIdUpload.ignore
|
|
2489
2497
|
});
|
|
2490
2498
|
|
|
2491
|
-
case
|
|
2499
|
+
case 13:
|
|
2492
2500
|
debugIdChunkFilePaths = _context4.sent.filter(function (p) {
|
|
2493
2501
|
return p.endsWith(".js") || p.endsWith(".mjs");
|
|
2494
2502
|
});
|
|
2495
2503
|
sourceFileUploadFolderPromise = util__default["default"].promisify(fs__default["default"].mkdtemp)(path__default["default"].join(os__default["default"].tmpdir(), "sentry-bundler-plugin-upload-"));
|
|
2496
|
-
_context4.next =
|
|
2504
|
+
_context4.next = 17;
|
|
2497
2505
|
return Promise.all(debugIdChunkFilePaths.map( /*#__PURE__*/function () {
|
|
2498
2506
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(chunkFilePath, chunkIndex) {
|
|
2499
2507
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
@@ -2525,46 +2533,46 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
2525
2533
|
};
|
|
2526
2534
|
}()));
|
|
2527
2535
|
|
|
2528
|
-
case
|
|
2529
|
-
_context4.next =
|
|
2536
|
+
case 17:
|
|
2537
|
+
_context4.next = 19;
|
|
2530
2538
|
return sourceFileUploadFolderPromise;
|
|
2531
2539
|
|
|
2532
|
-
case
|
|
2540
|
+
case 19:
|
|
2533
2541
|
tmpUploadFolder = _context4.sent;
|
|
2534
|
-
_context4.next =
|
|
2542
|
+
_context4.next = 22;
|
|
2535
2543
|
return uploadDebugIdSourcemaps(internalOptions, ctx, tmpUploadFolder, releaseName);
|
|
2536
2544
|
|
|
2537
|
-
case
|
|
2538
|
-
_context4.next =
|
|
2545
|
+
case 22:
|
|
2546
|
+
_context4.next = 24;
|
|
2539
2547
|
return createNewRelease(internalOptions, ctx, releaseName);
|
|
2540
2548
|
|
|
2541
|
-
case
|
|
2542
|
-
_context4.next =
|
|
2549
|
+
case 24:
|
|
2550
|
+
_context4.next = 26;
|
|
2543
2551
|
return cleanArtifacts(internalOptions, ctx, releaseName);
|
|
2544
2552
|
|
|
2545
|
-
case
|
|
2546
|
-
_context4.next =
|
|
2553
|
+
case 26:
|
|
2554
|
+
_context4.next = 28;
|
|
2547
2555
|
return uploadSourceMaps(internalOptions, ctx, releaseName);
|
|
2548
2556
|
|
|
2549
|
-
case
|
|
2550
|
-
_context4.next =
|
|
2557
|
+
case 28:
|
|
2558
|
+
_context4.next = 30;
|
|
2551
2559
|
return setCommits(internalOptions, ctx, releaseName);
|
|
2552
2560
|
|
|
2553
|
-
case
|
|
2554
|
-
_context4.next =
|
|
2561
|
+
case 30:
|
|
2562
|
+
_context4.next = 32;
|
|
2555
2563
|
return finalizeRelease(internalOptions, ctx, releaseName);
|
|
2556
2564
|
|
|
2557
|
-
case
|
|
2558
|
-
_context4.next =
|
|
2565
|
+
case 32:
|
|
2566
|
+
_context4.next = 34;
|
|
2559
2567
|
return addDeploy(internalOptions, ctx, releaseName);
|
|
2560
2568
|
|
|
2561
|
-
case
|
|
2569
|
+
case 34:
|
|
2562
2570
|
(_transaction = transaction) === null || _transaction === void 0 ? void 0 : _transaction.setStatus("ok");
|
|
2563
|
-
_context4.next =
|
|
2571
|
+
_context4.next = 42;
|
|
2564
2572
|
break;
|
|
2565
2573
|
|
|
2566
|
-
case
|
|
2567
|
-
_context4.prev =
|
|
2574
|
+
case 37:
|
|
2575
|
+
_context4.prev = 37;
|
|
2568
2576
|
_context4.t0 = _context4["catch"](8);
|
|
2569
2577
|
(_transaction2 = transaction) === null || _transaction2 === void 0 ? void 0 : _transaction2.setStatus("cancelled");
|
|
2570
2578
|
sentryHub.addBreadcrumb({
|
|
@@ -2573,8 +2581,8 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
2573
2581
|
});
|
|
2574
2582
|
handleError(_context4.t0, logger, internalOptions.errorHandler);
|
|
2575
2583
|
|
|
2576
|
-
case
|
|
2577
|
-
_context4.prev =
|
|
2584
|
+
case 42:
|
|
2585
|
+
_context4.prev = 42;
|
|
2578
2586
|
|
|
2579
2587
|
if (tmpUploadFolder) {
|
|
2580
2588
|
fs__default["default"].rm(tmpUploadFolder, {
|
|
@@ -2586,26 +2594,26 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
2586
2594
|
|
|
2587
2595
|
releasePipelineSpan === null || releasePipelineSpan === void 0 ? void 0 : releasePipelineSpan.finish();
|
|
2588
2596
|
(_transaction3 = transaction) === null || _transaction3 === void 0 ? void 0 : _transaction3.finish();
|
|
2589
|
-
_context4.next =
|
|
2597
|
+
_context4.next = 48;
|
|
2590
2598
|
return sentryClient.flush().then(null, function () {
|
|
2591
2599
|
logger.warn("Sending of telemetry failed");
|
|
2592
2600
|
});
|
|
2593
2601
|
|
|
2594
|
-
case 47:
|
|
2595
|
-
return _context4.finish(41);
|
|
2596
|
-
|
|
2597
2602
|
case 48:
|
|
2603
|
+
return _context4.finish(42);
|
|
2604
|
+
|
|
2605
|
+
case 49:
|
|
2598
2606
|
sentryHub.addBreadcrumb({
|
|
2599
2607
|
category: "writeBundle:finish",
|
|
2600
2608
|
level: "info"
|
|
2601
2609
|
});
|
|
2602
2610
|
|
|
2603
|
-
case
|
|
2611
|
+
case 50:
|
|
2604
2612
|
case "end":
|
|
2605
2613
|
return _context4.stop();
|
|
2606
2614
|
}
|
|
2607
2615
|
}
|
|
2608
|
-
}, _callee4, null, [[8,
|
|
2616
|
+
}, _callee4, null, [[8, 37, 42, 49]]);
|
|
2609
2617
|
}))();
|
|
2610
2618
|
},
|
|
2611
2619
|
rollup: {
|
|
@@ -2635,6 +2643,55 @@ var unplugin = unplugin$1.createUnplugin(function (options, unpluginMetaContext)
|
|
|
2635
2643
|
return null; // returning null means not modifying the chunk at all
|
|
2636
2644
|
}
|
|
2637
2645
|
}
|
|
2646
|
+
},
|
|
2647
|
+
webpack: function webpack(compiler) {
|
|
2648
|
+
var _options$_experiments3;
|
|
2649
|
+
|
|
2650
|
+
if ((_options$_experiments3 = options._experiments) !== null && _options$_experiments3 !== void 0 && _options$_experiments3.debugIdUpload) {
|
|
2651
|
+
// Cache inspired by https://github.com/webpack/webpack/pull/15454
|
|
2652
|
+
var cache = new WeakMap();
|
|
2653
|
+
compiler.hooks.compilation.tap("sentry-plugin", function (compilation) {
|
|
2654
|
+
compilation.hooks.optimizeChunkAssets.tap("sentry-plugin", function (chunks) {
|
|
2655
|
+
chunks.forEach(function (chunk) {
|
|
2656
|
+
var fileNames = chunk.files;
|
|
2657
|
+
fileNames.forEach(function (fileName) {
|
|
2658
|
+
var source = compilation.assets[fileName];
|
|
2659
|
+
|
|
2660
|
+
if (!source) {
|
|
2661
|
+
logger.warn("Unable to access compilation assets. If you see this warning, it is likely a bug in the Sentry webpack plugin. Feel free to open an issue at https://github.com/getsentry/sentry-javascript-bundler-plugins with reproduction steps.");
|
|
2662
|
+
return;
|
|
2663
|
+
}
|
|
2664
|
+
|
|
2665
|
+
compilation.updateAsset(fileName, function (oldSource) {
|
|
2666
|
+
var cached = cache.get(oldSource);
|
|
2667
|
+
|
|
2668
|
+
if (cached) {
|
|
2669
|
+
return cached;
|
|
2670
|
+
}
|
|
2671
|
+
|
|
2672
|
+
var originalCode = source.source().toString(); // The source map type is very annoying :(
|
|
2673
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
|
|
2674
|
+
|
|
2675
|
+
var originalSourceMap = source.map();
|
|
2676
|
+
|
|
2677
|
+
var _injectDebugIdSnippet = injectDebugIdSnippetIntoChunk(originalCode, fileName),
|
|
2678
|
+
newCode = _injectDebugIdSnippet.code,
|
|
2679
|
+
newSourceMap = _injectDebugIdSnippet.map; // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
2680
|
+
|
|
2681
|
+
|
|
2682
|
+
newSourceMap.sources = originalSourceMap.sources; // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
2683
|
+
|
|
2684
|
+
newSourceMap.sourcesContent = originalSourceMap.sourcesContent;
|
|
2685
|
+
var newSource = new webpackSources.SourceMapSource(newCode, fileName, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
2686
|
+
originalSourceMap, originalCode, newSourceMap, false);
|
|
2687
|
+
cache.set(oldSource, newSource);
|
|
2688
|
+
return newSource;
|
|
2689
|
+
});
|
|
2690
|
+
});
|
|
2691
|
+
});
|
|
2692
|
+
});
|
|
2693
|
+
});
|
|
2694
|
+
}
|
|
2638
2695
|
}
|
|
2639
2696
|
};
|
|
2640
2697
|
});
|