@sentry/bundler-plugins 11.11.0 → 11.13.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.
Files changed (188) hide show
  1. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/assertClassBrand.js +6 -0
  2. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/checkPrivateRedeclaration.js +5 -0
  3. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldGet2.js +6 -0
  4. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldInitSpec.js +6 -0
  5. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldSet2.js +6 -0
  6. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateMethodInitSpec.js +6 -0
  7. package/build/cjs/_virtual/_rolldown/runtime.js +22 -0
  8. package/build/cjs/babel-plugin/component-annotation.js +14 -32
  9. package/build/cjs/babel-plugin/component-annotation.js.map +1 -1
  10. package/build/cjs/babel-plugin/constants.js +140 -122
  11. package/build/cjs/babel-plugin/constants.js.map +1 -1
  12. package/build/cjs/babel-plugin/experimental.js +204 -307
  13. package/build/cjs/babel-plugin/experimental.js.map +1 -1
  14. package/build/cjs/babel-plugin/index.js +315 -437
  15. package/build/cjs/babel-plugin/index.js.map +1 -1
  16. package/build/cjs/bun/index.js +81 -117
  17. package/build/cjs/bun/index.js.map +1 -1
  18. package/build/cjs/core/build-plugin-manager.js +626 -683
  19. package/build/cjs/core/build-plugin-manager.js.map +1 -1
  20. package/build/cjs/core/cli.js +134 -129
  21. package/build/cjs/core/cli.js.map +1 -1
  22. package/build/cjs/core/component-annotate-hooks.js +16 -27
  23. package/build/cjs/core/component-annotate-hooks.js.map +1 -1
  24. package/build/cjs/core/component-annotation-oxc-ast.js +10 -21
  25. package/build/cjs/core/component-annotation-oxc-ast.js.map +1 -1
  26. package/build/cjs/core/component-annotation-oxc-fragments.js +45 -74
  27. package/build/cjs/core/component-annotation-oxc-fragments.js.map +1 -1
  28. package/build/cjs/core/component-annotation-oxc-jsx.js +116 -156
  29. package/build/cjs/core/component-annotation-oxc-jsx.js.map +1 -1
  30. package/build/cjs/core/component-annotation-oxc-walk.js +62 -123
  31. package/build/cjs/core/component-annotation-oxc-walk.js.map +1 -1
  32. package/build/cjs/core/component-annotation-oxc.js +68 -103
  33. package/build/cjs/core/component-annotation-oxc.js.map +1 -1
  34. package/build/cjs/core/debug-id-upload.js +223 -234
  35. package/build/cjs/core/debug-id-upload.js.map +1 -1
  36. package/build/cjs/core/get-code-injection-position.js +59 -74
  37. package/build/cjs/core/get-code-injection-position.js.map +1 -1
  38. package/build/cjs/core/glob.js +9 -7
  39. package/build/cjs/core/glob.js.map +1 -1
  40. package/build/cjs/core/index.js +77 -61
  41. package/build/cjs/core/index.js.map +1 -1
  42. package/build/cjs/core/logger.js +17 -26
  43. package/build/cjs/core/logger.js.map +1 -1
  44. package/build/cjs/core/options-mapping.js +95 -117
  45. package/build/cjs/core/options-mapping.js.map +1 -1
  46. package/build/cjs/core/sentry/telemetry.js +90 -105
  47. package/build/cjs/core/sentry/telemetry.js.map +1 -1
  48. package/build/cjs/core/sentry/transports.js +92 -99
  49. package/build/cjs/core/sentry/transports.js.map +1 -1
  50. package/build/cjs/core/sourcemap-settings.js +98 -61
  51. package/build/cjs/core/sourcemap-settings.js.map +1 -1
  52. package/build/cjs/core/upload-filter.js +52 -0
  53. package/build/cjs/core/upload-filter.js.map +1 -0
  54. package/build/cjs/core/utils.js +228 -219
  55. package/build/cjs/core/utils.js.map +1 -1
  56. package/build/cjs/core/version.js +4 -5
  57. package/build/cjs/core/version.js.map +1 -1
  58. package/build/cjs/esbuild/index.js +180 -210
  59. package/build/cjs/esbuild/index.js.map +1 -1
  60. package/build/cjs/loader-utils/index.js +5 -10
  61. package/build/cjs/rollup/debug-id-injection.js +22 -38
  62. package/build/cjs/rollup/debug-id-injection.js.map +1 -1
  63. package/build/cjs/rollup/debug-id-stamping.js +14 -24
  64. package/build/cjs/rollup/debug-id-stamping.js.map +1 -1
  65. package/build/cjs/rollup/index.js +195 -209
  66. package/build/cjs/rollup/index.js.map +1 -1
  67. package/build/cjs/rollup/source-map-handling.js +178 -0
  68. package/build/cjs/rollup/source-map-handling.js.map +1 -0
  69. package/build/cjs/vite/index.js +19 -35
  70. package/build/cjs/vite/index.js.map +1 -1
  71. package/build/cjs/vite/source-map-hooks.js +116 -0
  72. package/build/cjs/vite/source-map-hooks.js.map +1 -0
  73. package/build/cjs/webpack/component-annotation-transform.js +20 -26
  74. package/build/cjs/webpack/component-annotation-transform.js.map +1 -1
  75. package/build/cjs/webpack/index.js +277 -234
  76. package/build/cjs/webpack/index.js.map +1 -1
  77. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/assertClassBrand.js +6 -0
  78. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/checkPrivateRedeclaration.js +5 -0
  79. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldGet2.js +6 -0
  80. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldInitSpec.js +6 -0
  81. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldSet2.js +6 -0
  82. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateMethodInitSpec.js +6 -0
  83. package/build/esm/_virtual/_rolldown/runtime.js +2 -0
  84. package/build/esm/babel-plugin/component-annotation.js +13 -29
  85. package/build/esm/babel-plugin/component-annotation.js.map +1 -1
  86. package/build/esm/babel-plugin/constants.js +140 -120
  87. package/build/esm/babel-plugin/constants.js.map +1 -1
  88. package/build/esm/babel-plugin/experimental.js +204 -305
  89. package/build/esm/babel-plugin/experimental.js.map +1 -1
  90. package/build/esm/babel-plugin/index.js +311 -434
  91. package/build/esm/babel-plugin/index.js.map +1 -1
  92. package/build/esm/bun/index.js +76 -101
  93. package/build/esm/bun/index.js.map +1 -1
  94. package/build/esm/core/build-plugin-manager.js +621 -664
  95. package/build/esm/core/build-plugin-manager.js.map +1 -1
  96. package/build/esm/core/cli.js +134 -127
  97. package/build/esm/core/cli.js.map +1 -1
  98. package/build/esm/core/component-annotate-hooks.js +16 -25
  99. package/build/esm/core/component-annotate-hooks.js.map +1 -1
  100. package/build/esm/core/component-annotation-oxc-ast.js +9 -19
  101. package/build/esm/core/component-annotation-oxc-ast.js.map +1 -1
  102. package/build/esm/core/component-annotation-oxc-fragments.js +44 -72
  103. package/build/esm/core/component-annotation-oxc-fragments.js.map +1 -1
  104. package/build/esm/core/component-annotation-oxc-jsx.js +115 -154
  105. package/build/esm/core/component-annotation-oxc-jsx.js.map +1 -1
  106. package/build/esm/core/component-annotation-oxc-walk.js +61 -121
  107. package/build/esm/core/component-annotation-oxc-walk.js.map +1 -1
  108. package/build/esm/core/component-annotation-oxc.js +65 -96
  109. package/build/esm/core/component-annotation-oxc.js.map +1 -1
  110. package/build/esm/core/debug-id-upload.js +218 -213
  111. package/build/esm/core/debug-id-upload.js.map +1 -1
  112. package/build/esm/core/get-code-injection-position.js +59 -72
  113. package/build/esm/core/get-code-injection-position.js.map +1 -1
  114. package/build/esm/core/glob.js +9 -5
  115. package/build/esm/core/glob.js.map +1 -1
  116. package/build/esm/core/index.js +62 -47
  117. package/build/esm/core/index.js.map +1 -1
  118. package/build/esm/core/logger.js +17 -24
  119. package/build/esm/core/logger.js.map +1 -1
  120. package/build/esm/core/options-mapping.js +95 -115
  121. package/build/esm/core/options-mapping.js.map +1 -1
  122. package/build/esm/core/sentry/telemetry.js +89 -102
  123. package/build/esm/core/sentry/telemetry.js.map +1 -1
  124. package/build/esm/core/sentry/transports.js +90 -83
  125. package/build/esm/core/sentry/transports.js.map +1 -1
  126. package/build/esm/core/sourcemap-settings.js +96 -59
  127. package/build/esm/core/sourcemap-settings.js.map +1 -1
  128. package/build/esm/core/upload-filter.js +50 -0
  129. package/build/esm/core/upload-filter.js.map +1 -0
  130. package/build/esm/core/utils.js +221 -209
  131. package/build/esm/core/utils.js.map +1 -1
  132. package/build/esm/core/version.js +4 -3
  133. package/build/esm/core/version.js.map +1 -1
  134. package/build/esm/esbuild/index.js +176 -194
  135. package/build/esm/esbuild/index.js.map +1 -1
  136. package/build/esm/loader-utils/index.js +4 -3
  137. package/build/esm/package.json +1 -1
  138. package/build/esm/rollup/debug-id-injection.js +22 -36
  139. package/build/esm/rollup/debug-id-injection.js.map +1 -1
  140. package/build/esm/rollup/debug-id-stamping.js +14 -22
  141. package/build/esm/rollup/debug-id-stamping.js.map +1 -1
  142. package/build/esm/rollup/index.js +191 -189
  143. package/build/esm/rollup/index.js.map +1 -1
  144. package/build/esm/rollup/source-map-handling.js +173 -0
  145. package/build/esm/rollup/source-map-handling.js.map +1 -0
  146. package/build/esm/vite/index.js +19 -32
  147. package/build/esm/vite/index.js.map +1 -1
  148. package/build/esm/vite/source-map-hooks.js +114 -0
  149. package/build/esm/vite/source-map-hooks.js.map +1 -0
  150. package/build/esm/webpack/component-annotation-transform.js +17 -24
  151. package/build/esm/webpack/component-annotation-transform.js.map +1 -1
  152. package/build/esm/webpack/index.js +274 -216
  153. package/build/esm/webpack/index.js.map +1 -1
  154. package/build/types/core/build-plugin-manager.d.ts +33 -10
  155. package/build/types/core/build-plugin-manager.d.ts.map +1 -1
  156. package/build/types/core/cli.d.ts +6 -1
  157. package/build/types/core/cli.d.ts.map +1 -1
  158. package/build/types/core/debug-id-upload.d.ts +7 -4
  159. package/build/types/core/debug-id-upload.d.ts.map +1 -1
  160. package/build/types/core/index.d.ts +4 -3
  161. package/build/types/core/index.d.ts.map +1 -1
  162. package/build/types/core/options-mapping.d.ts +4 -3
  163. package/build/types/core/options-mapping.d.ts.map +1 -1
  164. package/build/types/core/sentry/telemetry.d.ts.map +1 -1
  165. package/build/types/core/sourcemap-settings.d.ts +10 -1
  166. package/build/types/core/sourcemap-settings.d.ts.map +1 -1
  167. package/build/types/core/types.d.ts +32 -1
  168. package/build/types/core/types.d.ts.map +1 -1
  169. package/build/types/core/upload-filter.d.ts +9 -0
  170. package/build/types/core/upload-filter.d.ts.map +1 -0
  171. package/build/types/core/utils.d.ts +4 -0
  172. package/build/types/core/utils.d.ts.map +1 -1
  173. package/build/types/core/version.d.ts +1 -1
  174. package/build/types/esbuild/index.d.ts +2 -2
  175. package/build/types/esbuild/index.d.ts.map +1 -1
  176. package/build/types/rollup/index.d.ts +107 -7
  177. package/build/types/rollup/index.d.ts.map +1 -1
  178. package/build/types/rollup/source-map-handling.d.ts +59 -0
  179. package/build/types/rollup/source-map-handling.d.ts.map +1 -0
  180. package/build/types/vite/index.d.ts +4 -8
  181. package/build/types/vite/index.d.ts.map +1 -1
  182. package/build/types/vite/source-map-hooks.d.ts +45 -0
  183. package/build/types/vite/source-map-hooks.d.ts.map +1 -0
  184. package/build/types/webpack/index.d.ts +7 -3
  185. package/build/types/webpack/index.d.ts.map +1 -1
  186. package/package.json +33 -38
  187. package/build/cjs/loader-utils/index.js.map +0 -1
  188. package/build/esm/loader-utils/index.js.map +0 -1
@@ -1,108 +1,101 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- const https = require('node:https');
4
- const node_stream = require('node:stream');
5
- const node_zlib = require('node:zlib');
6
- const core = require('@sentry/core');
7
- const path = require('node:path');
8
- const fs = require('node:fs');
9
-
10
- function _interopNamespace(e) {
11
- if (e && e.__esModule) return e;
12
- const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
13
- if (e) {
14
- for (const k in e) {
15
- n[k] = e[k];
16
- }
17
- }
18
- n.default = e;
19
- return n;
20
- }
21
-
22
- const https__namespace = /*#__PURE__*/_interopNamespace(https);
23
-
24
- const GZIP_THRESHOLD = 1024 * 32;
1
+ const require_runtime = require("../../_virtual/_rolldown/runtime.js");
2
+ let node_path = require("node:path");
3
+ let _sentry_core = require("@sentry/core");
4
+ let node_https = require("node:https");
5
+ node_https = require_runtime.__toESM(node_https);
6
+ let node_stream = require("node:stream");
7
+ let node_zlib = require("node:zlib");
8
+ let node_fs = require("node:fs");
9
+ // src/core/sentry/transports.ts
10
+ /**
11
+ * This is a simplified version of the Sentry Node SDK's HTTP transport.
12
+ */
13
+ const GZIP_THRESHOLD = 32768;
14
+ /**
15
+ * Gets a stream from a Uint8Array or string
16
+ * Readable.from is ideal but was added in node.js v12.3.0 and v10.17.0
17
+ */
25
18
  function streamFromBody(body) {
26
- return new node_stream.Readable({
27
- read() {
28
- this.push(body);
29
- this.push(null);
30
- }
31
- });
19
+ return new node_stream.Readable({ read() {
20
+ this.push(body);
21
+ this.push(null);
22
+ } });
32
23
  }
24
+ /**
25
+ * Creates a RequestExecutor to be used with `createTransport`.
26
+ */
33
27
  function createRequestExecutor(options) {
34
- const { hostname, pathname, port, protocol, search } = new URL(options.url);
35
- return function makeRequest(request) {
36
- return new Promise((resolve, reject) => {
37
- core.suppressTracing(() => {
38
- let body = streamFromBody(request.body);
39
- const headers = {};
40
- if (request.body.length > GZIP_THRESHOLD) {
41
- headers["content-encoding"] = "gzip";
42
- body = body.pipe(node_zlib.createGzip());
43
- }
44
- const req = https__namespace.request(
45
- {
46
- method: "POST",
47
- headers,
48
- hostname,
49
- path: `${pathname}${search}`,
50
- port,
51
- protocol
52
- },
53
- (res) => {
54
- res.on("data", () => {
55
- });
56
- res.on("end", () => {
57
- });
58
- res.setEncoding("utf8");
59
- const retryAfterHeader = res.headers["retry-after"] ?? null;
60
- const rateLimitsHeader = res.headers["x-sentry-rate-limits"] ?? null;
61
- resolve({
62
- statusCode: res.statusCode,
63
- headers: {
64
- "retry-after": retryAfterHeader,
65
- "x-sentry-rate-limits": Array.isArray(rateLimitsHeader) ? rateLimitsHeader[0] || null : rateLimitsHeader
66
- }
67
- });
68
- }
69
- );
70
- req.on("error", reject);
71
- body.pipe(req);
72
- });
73
- });
74
- };
28
+ const { hostname, pathname, port, protocol, search } = new URL(options.url);
29
+ return function makeRequest(request) {
30
+ return new Promise((resolve, reject) => {
31
+ (0, _sentry_core.suppressTracing)(() => {
32
+ let body = streamFromBody(request.body);
33
+ const headers = {};
34
+ if (request.body.length > GZIP_THRESHOLD) {
35
+ headers["content-encoding"] = "gzip";
36
+ body = body.pipe((0, node_zlib.createGzip)());
37
+ }
38
+ const req = node_https.request({
39
+ method: "POST",
40
+ headers,
41
+ hostname,
42
+ path: `${pathname}${search}`,
43
+ port,
44
+ protocol
45
+ }, (res) => {
46
+ res.on("data", () => {});
47
+ res.on("end", () => {});
48
+ res.setEncoding("utf8");
49
+ const retryAfterHeader = res.headers["retry-after"] ?? null;
50
+ const rateLimitsHeader = res.headers["x-sentry-rate-limits"] ?? null;
51
+ resolve({
52
+ statusCode: res.statusCode,
53
+ headers: {
54
+ "retry-after": retryAfterHeader,
55
+ "x-sentry-rate-limits": Array.isArray(rateLimitsHeader) ? rateLimitsHeader[0] || null : rateLimitsHeader
56
+ }
57
+ });
58
+ });
59
+ req.on("error", reject);
60
+ body.pipe(req);
61
+ });
62
+ });
63
+ };
75
64
  }
65
+ /**
66
+ * Creates a Transport that uses native the native 'http' and 'https' modules to send events to Sentry.
67
+ */
76
68
  function makeNodeTransport(options) {
77
- const requestExecutor = createRequestExecutor(options);
78
- return core.createTransport(options, requestExecutor);
69
+ const requestExecutor = createRequestExecutor(options);
70
+ return (0, _sentry_core.createTransport)(options, requestExecutor);
79
71
  }
72
+ /** A transport that can be optionally enabled as a later time than it's
73
+ * creation */
80
74
  function makeOptionallyEnabledNodeTransport(shouldSendTelemetry) {
81
- return (nodeTransportOptions) => {
82
- const nodeTransport = makeNodeTransport(nodeTransportOptions);
83
- return {
84
- flush: (timeout) => nodeTransport.flush(timeout),
85
- send: async (request) => {
86
- if ("__SENTRY_INTERCEPT_TRANSPORT__" in global && Array.isArray(global.__SENTRY_INTERCEPT_TRANSPORT__)) {
87
- global.__SENTRY_INTERCEPT_TRANSPORT__.push(request);
88
- return { statusCode: 200 };
89
- }
90
- if (await shouldSendTelemetry) {
91
- if (process.env["SENTRY_TEST_OUT_DIR"]) {
92
- const outDir = process.env["SENTRY_TEST_OUT_DIR"];
93
- fs.mkdirSync(outDir, { recursive: true });
94
- const path$1 = path.join(outDir, "sentry-telemetry.json");
95
- fs.appendFileSync(path$1, `${JSON.stringify(request)},
96
- `);
97
- return { statusCode: 200 };
98
- }
99
- return nodeTransport.send(request);
100
- }
101
- return { statusCode: 200 };
102
- }
103
- };
104
- };
75
+ return (nodeTransportOptions) => {
76
+ const nodeTransport = makeNodeTransport(nodeTransportOptions);
77
+ return {
78
+ flush: (timeout) => nodeTransport.flush(timeout),
79
+ send: async (request) => {
80
+ if ("__SENTRY_INTERCEPT_TRANSPORT__" in global && Array.isArray(global.__SENTRY_INTERCEPT_TRANSPORT__)) {
81
+ global.__SENTRY_INTERCEPT_TRANSPORT__.push(request);
82
+ return { statusCode: 200 };
83
+ }
84
+ if (await shouldSendTelemetry) {
85
+ if (process.env["SENTRY_TEST_OUT_DIR"]) {
86
+ const outDir = process.env["SENTRY_TEST_OUT_DIR"];
87
+ (0, node_fs.mkdirSync)(outDir, { recursive: true });
88
+ const path = (0, node_path.join)(outDir, "sentry-telemetry.json");
89
+ (0, node_fs.appendFileSync)(path, `${JSON.stringify(request)},\n`);
90
+ return { statusCode: 200 };
91
+ }
92
+ return nodeTransport.send(request);
93
+ }
94
+ return { statusCode: 200 };
95
+ }
96
+ };
97
+ };
105
98
  }
106
-
107
99
  exports.makeOptionallyEnabledNodeTransport = makeOptionallyEnabledNodeTransport;
108
- //# sourceMappingURL=transports.js.map
100
+
101
+ //# sourceMappingURL=transports.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transports.js","sources":["../../../../src/core/sentry/transports.ts"],"sourcesContent":["/**\n * This is a simplified version of the Sentry Node SDK's HTTP transport.\n */\nimport * as https from 'node:https';\nimport { Readable } from 'node:stream';\nimport { createGzip } from 'node:zlib';\nimport { createTransport, suppressTracing } from '@sentry/core';\nimport type {\n BaseTransportOptions,\n Transport,\n TransportMakeRequestResponse,\n TransportRequest,\n TransportRequestExecutor,\n} from '@sentry/core';\nimport { join } from 'node:path';\nimport { appendFileSync, mkdirSync } from 'node:fs';\n\n// Estimated maximum size for reasonable standalone event\nconst GZIP_THRESHOLD = 1024 * 32;\n\n/**\n * Gets a stream from a Uint8Array or string\n * Readable.from is ideal but was added in node.js v12.3.0 and v10.17.0\n */\nfunction streamFromBody(body: Uint8Array | string): Readable {\n return new Readable({\n read() {\n this.push(body);\n this.push(null);\n },\n });\n}\n\n/**\n * Creates a RequestExecutor to be used with `createTransport`.\n */\nfunction createRequestExecutor(options: BaseTransportOptions): TransportRequestExecutor {\n const { hostname, pathname, port, protocol, search } = new URL(options.url);\n return function makeRequest(request: TransportRequest): Promise<TransportMakeRequestResponse> {\n return new Promise((resolve, reject) => {\n suppressTracing(() => {\n let body = streamFromBody(request.body);\n\n const headers: Record<string, string> = {};\n\n if (request.body.length > GZIP_THRESHOLD) {\n headers['content-encoding'] = 'gzip';\n body = body.pipe(createGzip());\n }\n\n const req = https.request(\n {\n method: 'POST',\n headers,\n hostname,\n path: `${pathname}${search}`,\n port,\n protocol,\n },\n res => {\n res.on('data', () => {\n // Drain socket\n });\n\n res.on('end', () => {\n // Drain socket\n });\n\n res.setEncoding('utf8');\n\n // \"Key-value pairs of header names and values. Header names are lower-cased.\"\n // https://nodejs.org/api/http.html#http_message_headers\n const retryAfterHeader = res.headers['retry-after'] ?? null;\n const rateLimitsHeader = res.headers['x-sentry-rate-limits'] ?? null;\n\n resolve({\n statusCode: res.statusCode,\n headers: {\n 'retry-after': retryAfterHeader,\n 'x-sentry-rate-limits': Array.isArray(rateLimitsHeader)\n ? rateLimitsHeader[0] || null\n : rateLimitsHeader,\n },\n });\n },\n );\n\n req.on('error', reject);\n body.pipe(req);\n });\n });\n };\n}\n\n/**\n * Creates a Transport that uses native the native 'http' and 'https' modules to send events to Sentry.\n */\nfunction makeNodeTransport(options: BaseTransportOptions): Transport {\n const requestExecutor = createRequestExecutor(options);\n return createTransport(options, requestExecutor);\n}\n\n/** A transport that can be optionally enabled as a later time than it's\n * creation */\nexport function makeOptionallyEnabledNodeTransport(\n shouldSendTelemetry: Promise<boolean>,\n): (options: BaseTransportOptions) => Transport {\n return nodeTransportOptions => {\n const nodeTransport = makeNodeTransport(nodeTransportOptions);\n\n return {\n flush: timeout => nodeTransport.flush(timeout),\n send: async request => {\n // If global.__SENTRY_INTERCEPT_TRANSPORT__ is an array, we push the\n // envelope into it for testing purposes.\n if ('__SENTRY_INTERCEPT_TRANSPORT__' in global && Array.isArray(global.__SENTRY_INTERCEPT_TRANSPORT__)) {\n global.__SENTRY_INTERCEPT_TRANSPORT__.push(request);\n return { statusCode: 200 };\n }\n\n if (await shouldSendTelemetry) {\n if (process.env['SENTRY_TEST_OUT_DIR']) {\n const outDir = process.env['SENTRY_TEST_OUT_DIR'];\n mkdirSync(outDir, { recursive: true });\n const path = join(outDir, 'sentry-telemetry.json');\n appendFileSync(path, `${JSON.stringify(request)},\\n`);\n return { statusCode: 200 };\n }\n\n return nodeTransport.send(request);\n }\n\n return { statusCode: 200 };\n },\n };\n };\n}\n"],"names":["Readable","suppressTracing","createGzip","https","createTransport","mkdirSync","path","join","appendFileSync"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAM,iBAAiB,IAAA,GAAO,EAAA;AAM9B,SAAS,eAAe,IAAA,EAAqC;AAC3D,EAAA,OAAO,IAAIA,oBAAA,CAAS;AAAA,IAClB,IAAA,GAAO;AACL,MAAA,IAAA,CAAK,KAAK,IAAI,CAAA;AACd,MAAA,IAAA,CAAK,KAAK,IAAI,CAAA;AAAA,IAChB;AAAA,GACD,CAAA;AACH;AAKA,SAAS,sBAAsB,OAAA,EAAyD;AACtF,EAAA,MAAM,EAAE,QAAA,EAAU,QAAA,EAAU,IAAA,EAAM,QAAA,EAAU,QAAO,GAAI,IAAI,GAAA,CAAI,OAAA,CAA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AAeF,MAAA,EAAM,CAAA,EAAG,IAAA,CAAK,SAAA,CAAU,OAAO,CAAC,CAAA;AAAA,CAAK,CAAA;AACpD,YAAA,OAAO,EAAE,YAAY,GAAA,EAAI;AAAA,UAC3B;AAEA,UAAA,OAAO,aAAA,CAAc,KAAK,OAAO,CAAA;AAAA,QACnC;AAEA,QAAA,OAAO,EAAE,YAAY,GAAA,EAAI;AAAA,MAC3B;AAAA,KACF;AAAA,EACF,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"transports.js","names":["Readable","suppressTracing","createGzip","https","createTransport","mkdirSync","join","appendFileSync"],"sources":["../../../../src/core/sentry/transports.ts"],"sourcesContent":["/**\n * This is a simplified version of the Sentry Node SDK's HTTP transport.\n */\nimport * as https from 'node:https';\nimport { Readable } from 'node:stream';\nimport { createGzip } from 'node:zlib';\nimport { createTransport, suppressTracing } from '@sentry/core';\nimport type {\n BaseTransportOptions,\n Transport,\n TransportMakeRequestResponse,\n TransportRequest,\n TransportRequestExecutor,\n} from '@sentry/core';\nimport { join } from 'node:path';\nimport { appendFileSync, mkdirSync } from 'node:fs';\n\n// Estimated maximum size for reasonable standalone event\nconst GZIP_THRESHOLD = 1024 * 32;\n\n/**\n * Gets a stream from a Uint8Array or string\n * Readable.from is ideal but was added in node.js v12.3.0 and v10.17.0\n */\nfunction streamFromBody(body: Uint8Array | string): Readable {\n return new Readable({\n read() {\n this.push(body);\n this.push(null);\n },\n });\n}\n\n/**\n * Creates a RequestExecutor to be used with `createTransport`.\n */\nfunction createRequestExecutor(options: BaseTransportOptions): TransportRequestExecutor {\n const { hostname, pathname, port, protocol, search } = new URL(options.url);\n return function makeRequest(request: TransportRequest): Promise<TransportMakeRequestResponse> {\n return new Promise((resolve, reject) => {\n suppressTracing(() => {\n let body = streamFromBody(request.body);\n\n const headers: Record<string, string> = {};\n\n if (request.body.length > GZIP_THRESHOLD) {\n headers['content-encoding'] = 'gzip';\n body = body.pipe(createGzip());\n }\n\n const req = https.request(\n {\n method: 'POST',\n headers,\n hostname,\n path: `${pathname}${search}`,\n port,\n protocol,\n },\n res => {\n res.on('data', () => {\n // Drain socket\n });\n\n res.on('end', () => {\n // Drain socket\n });\n\n res.setEncoding('utf8');\n\n // \"Key-value pairs of header names and values. Header names are lower-cased.\"\n // https://nodejs.org/api/http.html#http_message_headers\n const retryAfterHeader = res.headers['retry-after'] ?? null;\n const rateLimitsHeader = res.headers['x-sentry-rate-limits'] ?? null;\n\n resolve({\n statusCode: res.statusCode,\n headers: {\n 'retry-after': retryAfterHeader,\n 'x-sentry-rate-limits': Array.isArray(rateLimitsHeader)\n ? rateLimitsHeader[0] || null\n : rateLimitsHeader,\n },\n });\n },\n );\n\n req.on('error', reject);\n body.pipe(req);\n });\n });\n };\n}\n\n/**\n * Creates a Transport that uses native the native 'http' and 'https' modules to send events to Sentry.\n */\nfunction makeNodeTransport(options: BaseTransportOptions): Transport {\n const requestExecutor = createRequestExecutor(options);\n return createTransport(options, requestExecutor);\n}\n\n/** A transport that can be optionally enabled as a later time than it's\n * creation */\nexport function makeOptionallyEnabledNodeTransport(\n shouldSendTelemetry: Promise<boolean>,\n): (options: BaseTransportOptions) => Transport {\n return nodeTransportOptions => {\n const nodeTransport = makeNodeTransport(nodeTransportOptions);\n\n return {\n flush: timeout => nodeTransport.flush(timeout),\n send: async request => {\n // If global.__SENTRY_INTERCEPT_TRANSPORT__ is an array, we push the\n // envelope into it for testing purposes.\n if ('__SENTRY_INTERCEPT_TRANSPORT__' in global && Array.isArray(global.__SENTRY_INTERCEPT_TRANSPORT__)) {\n global.__SENTRY_INTERCEPT_TRANSPORT__.push(request);\n return { statusCode: 200 };\n }\n\n if (await shouldSendTelemetry) {\n if (process.env['SENTRY_TEST_OUT_DIR']) {\n const outDir = process.env['SENTRY_TEST_OUT_DIR'];\n mkdirSync(outDir, { recursive: true });\n const path = join(outDir, 'sentry-telemetry.json');\n appendFileSync(path, `${JSON.stringify(request)},\\n`);\n return { statusCode: 200 };\n }\n\n return nodeTransport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AOC,aAAAA,gBAAAA,CAAgB,SAAS,eAAe;AACjD;;;AAIA,SAAgB,mCACd,qBAC8C;CAC9C,QAAO,yBAAwB;EAC7B,MAAM,gBAAgB,kBAAkB,oBAAoB;EAE5D,OAAO;GACL,QAAO,YAAW,cAAc,MAAM,OAAO;GAC7C,MAAM,OAAM,YAAW;IAGrB,IAAI,oCAAoC,UAAU,MAAM,QAAQ,OAAO,8BAA8B,GAAG;KACtG,OAAO,+BAA+B,KAAK,OAAO;KAClD,OAAO,EAAE,YAAY,IAAI;IAC3B;IAEA,IAAI,MAAM,qBAAqB;KAC7B,IAAI,QAAQ,IAAI,wBAAwB;MACtC,MAAM,SAAS,QAAQ,IAAI;MAC3BC,CAAAA,GAAAA,QAAAA,UAAAA,CAAU,QAAQ,EAAE,WAAW,KAAK,CAAC;MACrC,MAAM,QAAA,GAAOC,UAAAA,KAAAA,CAAK,QAAQ,uBAAuB;MACjDC,CAAAA,GAAAA,QAAAA,eAAAA,CAAe,MAAM,GAAG,KAAK,UAAU,OAAO,EAAE,IAAI;MACpD,OAAO,EAAE,YAAY,IAAI;KAC3B;KAEA,OAAO,cAAc,KAAK,OAAO;IACnC;IAEA,OAAO,EAAE,YAAY,IAAI;GAC3B;EACF;CACF;AACF"}
@@ -1,63 +1,100 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- const NO_CHANGE = { enableHidden: false, deleteAfterUpload: false };
4
- function decideSourceMapHandling(kind, options, uploadPossible) {
5
- const deleteOption = options.sourcemaps?.deleteSourcemapsAfterUpload;
6
- if (!uploadPossible || options.sourcemaps?.disable) {
7
- return NO_CHANGE;
8
- }
9
- switch (kind) {
10
- case "off":
11
- return {
12
- ...NO_CHANGE,
13
- log: {
14
- level: "warn",
15
- message: "Source map generation is turned off in your bundler, so Sentry cannot un-minify your stack traces. Remove the setting to let the plugin generate hidden source maps, upload them to Sentry and remove them from the build output."
16
- }
17
- };
18
- case "inline":
19
- return {
20
- ...NO_CHANGE,
21
- log: {
22
- level: "warn",
23
- message: "Source maps are inlined into your bundles. They are uploaded to Sentry, but inline source maps ship your source code to users and cannot be removed after the upload. Remove the setting to let the plugin generate hidden source maps instead."
24
- }
25
- };
26
- case "unset":
27
- if (deleteOption === false) {
28
- return {
29
- enableHidden: true,
30
- deleteAfterUpload: false,
31
- log: {
32
- level: "info",
33
- message: "Enabling hidden source maps. They are uploaded to Sentry and kept in the build output."
34
- }
35
- };
36
- }
37
- return {
38
- enableHidden: true,
39
- deleteAfterUpload: true,
40
- log: {
41
- level: "info",
42
- message: "Enabling hidden source maps. They are uploaded to Sentry and removed from the build output. Set `sourcemaps.deleteSourcemapsAfterUpload: false` to keep them."
43
- }
44
- };
45
- case "hidden":
46
- return { enableHidden: false, deleteAfterUpload: deleteOption === true };
47
- case "visible":
48
- if (deleteOption !== true) {
49
- return NO_CHANGE;
50
- }
51
- return {
52
- enableHidden: true,
53
- deleteAfterUpload: true,
54
- log: {
55
- level: "info",
56
- message: "Switching to hidden source maps because `sourcemaps.deleteSourcemapsAfterUpload` is set. Without the `sourceMappingURL` comment browsers do not request the removed map files."
57
- }
58
- };
59
- }
1
+ // src/core/sourcemap-settings.ts
2
+ const NO_CHANGE = {
3
+ enableHidden: false,
4
+ deleteAfterUpload: false
5
+ };
6
+ /** Reads `sourcemaps.deleteSourcemapsAfterUpload`, calling the internal function form if given. */
7
+ function getDeleteSourcemapsAfterUpload(options, environment) {
8
+ const value = options.sourcemaps?.deleteSourcemapsAfterUpload;
9
+ return typeof value === "function" ? value(environment) : value;
10
+ }
11
+ /** Reads the internal `sourcemaps.sdkEnabledSourceMaps` option, calling its function form if given. */
12
+ function getSdkEnabledSourceMaps(options, environment) {
13
+ const value = options.sourcemaps?.sdkEnabledSourceMaps;
14
+ return (typeof value === "function" ? value(environment) : value) === true;
15
+ }
16
+ /**
17
+ * Decides whether the plugin turns hidden source maps on and whether it removes the maps from the
18
+ * build output after the upload. The plugin only turns maps on when an upload can run, and only
19
+ * removes maps it turned on itself unless `deleteSourcemapsAfterUpload` says otherwise.
20
+ */
21
+ function decideSourceMapHandling(kind, options, uploadPossible, environment) {
22
+ const deleteOption = getDeleteSourcemapsAfterUpload(options, environment);
23
+ const sdkEnabledSourceMaps = getSdkEnabledSourceMaps(options, environment);
24
+ if (!uploadPossible || options.sourcemaps?.disable) {
25
+ if (deleteOption !== true || kind !== "hidden" && kind !== "visible") return NO_CHANGE;
26
+ if (options.sourcemaps?.disable && !sdkEnabledSourceMaps) return {
27
+ ...NO_CHANGE,
28
+ log: {
29
+ level: "warn",
30
+ message: "`sourcemaps.deleteSourcemapsAfterUpload` is set, but source map upload is disabled with `sourcemaps.disable`, so the source maps are not removed."
31
+ }
32
+ };
33
+ return {
34
+ enableHidden: kind === "visible",
35
+ deleteAfterUpload: true,
36
+ removeAllSourceMaps: sdkEnabledSourceMaps,
37
+ log: {
38
+ level: "warn",
39
+ message: "Source maps are not uploaded, but they are removed from the build output because `sourcemaps.deleteSourcemapsAfterUpload` is set."
40
+ }
41
+ };
42
+ }
43
+ switch (kind) {
44
+ case "off": return {
45
+ ...NO_CHANGE,
46
+ log: {
47
+ level: "warn",
48
+ message: "Source map generation is turned off in your bundler, so Sentry cannot un-minify your stack traces. Remove the setting to let the plugin generate hidden source maps, upload them to Sentry and remove them from the build output."
49
+ }
50
+ };
51
+ case "inline": return {
52
+ ...NO_CHANGE,
53
+ log: {
54
+ level: "warn",
55
+ message: "Source maps are inlined into your bundles. They are uploaded to Sentry, but inline source maps ship your source code to users and cannot be removed after the upload. Remove the setting to let the plugin generate hidden source maps instead."
56
+ }
57
+ };
58
+ case "unset":
59
+ if (deleteOption === false) return {
60
+ enableHidden: true,
61
+ deleteAfterUpload: false,
62
+ log: {
63
+ level: "info",
64
+ message: "Enabling hidden source maps. They are uploaded to Sentry and kept in the build output."
65
+ }
66
+ };
67
+ return {
68
+ enableHidden: true,
69
+ deleteAfterUpload: true,
70
+ removeAllSourceMaps: true,
71
+ log: {
72
+ level: "info",
73
+ message: "Enabling hidden source maps. They are uploaded to Sentry and removed from the build output. Set `sourcemaps.deleteSourcemapsAfterUpload: false` to keep them."
74
+ }
75
+ };
76
+ case "hidden":
77
+ if (deleteOption !== true) return NO_CHANGE;
78
+ return {
79
+ enableHidden: false,
80
+ deleteAfterUpload: true,
81
+ removeAllSourceMaps: sdkEnabledSourceMaps
82
+ };
83
+ case "visible":
84
+ if (deleteOption !== true) return NO_CHANGE;
85
+ return {
86
+ enableHidden: true,
87
+ deleteAfterUpload: true,
88
+ removeAllSourceMaps: sdkEnabledSourceMaps,
89
+ log: {
90
+ level: "info",
91
+ message: "Switching to hidden source maps because `sourcemaps.deleteSourcemapsAfterUpload` is set. Without the `sourceMappingURL` comment browsers do not request the removed map files."
92
+ }
93
+ };
94
+ }
60
95
  }
61
-
62
96
  exports.decideSourceMapHandling = decideSourceMapHandling;
63
- //# sourceMappingURL=sourcemap-settings.js.map
97
+ exports.getDeleteSourcemapsAfterUpload = getDeleteSourcemapsAfterUpload;
98
+ exports.getSdkEnabledSourceMaps = getSdkEnabledSourceMaps;
99
+
100
+ //# sourceMappingURL=sourcemap-settings.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sourcemap-settings.js","sources":["../../../src/core/sourcemap-settings.ts"],"sourcesContent":["import type { NormalizedOptions } from './options-mapping';\n\n/**\n * The user's source map setting in the bundler, reduced to what matters for upload and deletion.\n *\n * - `unset`: the user did not configure source maps\n * - `off`: source map generation is turned off\n * - `visible`: separate map files with a `sourceMappingURL` comment\n * - `hidden`: separate map files without the comment\n * - `inline`: the map is embedded into the bundle\n */\nexport type SourceMapKind = 'unset' | 'off' | 'visible' | 'hidden' | 'inline';\n\nexport type SourceMapDecision = {\n /** Switch the bundler to hidden source maps. */\n enableHidden: boolean;\n /** Remove the source maps from the build output once they are uploaded. */\n deleteAfterUpload: boolean;\n log?: { level: 'info' | 'warn'; message: string };\n};\n\nconst NO_CHANGE: SourceMapDecision = { enableHidden: false, deleteAfterUpload: false };\n\n/**\n * Decides whether the plugin turns hidden source maps on and whether it removes the maps from the\n * build output after the upload. The plugin only turns maps on when an upload can run, and only\n * removes maps it turned on itself unless `deleteSourcemapsAfterUpload` says otherwise.\n */\nexport function decideSourceMapHandling(\n kind: SourceMapKind,\n options: NormalizedOptions,\n uploadPossible: boolean,\n): SourceMapDecision {\n const deleteOption = options.sourcemaps?.deleteSourcemapsAfterUpload;\n\n if (!uploadPossible || options.sourcemaps?.disable) {\n return NO_CHANGE;\n }\n\n switch (kind) {\n case 'off':\n return {\n ...NO_CHANGE,\n log: {\n level: 'warn',\n message:\n 'Source map generation is turned off in your bundler, so Sentry cannot un-minify your stack traces. ' +\n 'Remove the setting to let the plugin generate hidden source maps, upload them to Sentry and remove them from the build output.',\n },\n };\n\n case 'inline':\n return {\n ...NO_CHANGE,\n log: {\n level: 'warn',\n message:\n 'Source maps are inlined into your bundles. They are uploaded to Sentry, but inline source maps ship your source code to users and cannot be removed after the upload. ' +\n 'Remove the setting to let the plugin generate hidden source maps instead.',\n },\n };\n\n case 'unset':\n if (deleteOption === false) {\n return {\n enableHidden: true,\n deleteAfterUpload: false,\n log: {\n level: 'info',\n message: 'Enabling hidden source maps. They are uploaded to Sentry and kept in the build output.',\n },\n };\n }\n return {\n enableHidden: true,\n deleteAfterUpload: true,\n log: {\n level: 'info',\n message:\n 'Enabling hidden source maps. They are uploaded to Sentry and removed from the build output. ' +\n 'Set `sourcemaps.deleteSourcemapsAfterUpload: false` to keep them.',\n },\n };\n\n case 'hidden':\n return { enableHidden: false, deleteAfterUpload: deleteOption === true };\n\n case 'visible':\n if (deleteOption !== true) {\n return NO_CHANGE;\n }\n return {\n enableHidden: true,\n deleteAfterUpload: true,\n log: {\n level: 'info',\n message:\n 'Switching to hidden source maps because `sourcemaps.deleteSourcemapsAfterUpload` is set. ' +\n 'Without the `sourceMappingURL` comment browsers do not request the removed map files.',\n },\n };\n }\n}\n"],"names":[],"mappings":";;AAqBA,MAAM,SAAA,GAA+B,EAAE,YAA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AO;AAAA,QACL,YAAA,EAAc,IAAA;AAAA,QACd,iBAAA,EAAmB,IAAA;AAAA,QACnB,GAAA,EAAK;AAAA,UACH,KAAA,EAAO,MAAA;AAAA,UACP,OAAA,EACE;AAAA;AAEJ,OACF;AAAA;AAEN;;;;"}
1
+ {"version":3,"file":"sourcemap-settings.js","names":[],"sources":["../../../src/core/sourcemap-settings.ts"],"sourcesContent":["import type { NormalizedOptions } from './options-mapping';\n\n/**\n * The user's source map setting in the bundler, reduced to what matters for upload and deletion.\n *\n * - `unset`: the user did not configure source maps\n * - `off`: source map generation is turned off\n * - `visible`: separate map files with a `sourceMappingURL` comment\n * - `hidden`: separate map files without the comment\n * - `inline`: the map is embedded into the bundle\n */\nexport type SourceMapKind = 'unset' | 'off' | 'visible' | 'hidden' | 'inline';\n\nexport type SourceMapDecision = {\n /** Switch the bundler to hidden source maps. */\n enableHidden: boolean;\n /** Remove the source maps from the build output once they are uploaded. */\n deleteAfterUpload: boolean;\n /**\n * With `deleteAfterUpload`, remove every source map of the build, also those of CSS and of chunks\n * the upload leaves out. Set when the plugin or the SDK turned the source maps on.\n */\n removeAllSourceMaps?: boolean;\n log?: { level: 'info' | 'warn'; message: string };\n};\n\nconst NO_CHANGE: SourceMapDecision = { enableHidden: false, deleteAfterUpload: false };\n\n/** Reads `sourcemaps.deleteSourcemapsAfterUpload`, calling the internal function form if given. */\nexport function getDeleteSourcemapsAfterUpload(options: NormalizedOptions, environment?: string): boolean | undefined {\n const value = options.sourcemaps?.deleteSourcemapsAfterUpload;\n return typeof value === 'function' ? value(environment) : value;\n}\n\n/** Reads the internal `sourcemaps.sdkEnabledSourceMaps` option, calling its function form if given. */\nexport function getSdkEnabledSourceMaps(options: NormalizedOptions, environment?: string): boolean {\n const value = options.sourcemaps?.sdkEnabledSourceMaps;\n return (typeof value === 'function' ? value(environment) : value) === true;\n}\n\n/**\n * Decides whether the plugin turns hidden source maps on and whether it removes the maps from the\n * build output after the upload. The plugin only turns maps on when an upload can run, and only\n * removes maps it turned on itself unless `deleteSourcemapsAfterUpload` says otherwise.\n */\nexport function decideSourceMapHandling(\n kind: SourceMapKind,\n options: NormalizedOptions,\n uploadPossible: boolean,\n environment?: string,\n): SourceMapDecision {\n const deleteOption = getDeleteSourcemapsAfterUpload(options, environment);\n const sdkEnabledSourceMaps = getSdkEnabledSourceMaps(options, environment);\n\n if (!uploadPossible || options.sourcemaps?.disable) {\n if (deleteOption !== true || (kind !== 'hidden' && kind !== 'visible')) {\n return NO_CHANGE;\n }\n // Users set `sourcemaps.disable` to upload the maps themselves. Maps the\n // SDK turned on are still removed, as the SDKs' own globs did.\n if (options.sourcemaps?.disable && !sdkEnabledSourceMaps) {\n return {\n ...NO_CHANGE,\n log: {\n level: 'warn',\n message:\n '`sourcemaps.deleteSourcemapsAfterUpload` is set, but source map upload is disabled with `sourcemaps.disable`, so the source maps are not removed.',\n },\n };\n }\n return {\n enableHidden: kind === 'visible',\n deleteAfterUpload: true,\n removeAllSourceMaps: sdkEnabledSourceMaps,\n log: {\n level: 'warn',\n message:\n 'Source maps are not uploaded, but they are removed from the build output because `sourcemaps.deleteSourcemapsAfterUpload` is set.',\n },\n };\n }\n\n switch (kind) {\n case 'off':\n return {\n ...NO_CHANGE,\n log: {\n level: 'warn',\n message:\n 'Source map generation is turned off in your bundler, so Sentry cannot un-minify your stack traces. ' +\n 'Remove the setting to let the plugin generate hidden source maps, upload them to Sentry and remove them from the build output.',\n },\n };\n\n case 'inline':\n return {\n ...NO_CHANGE,\n log: {\n level: 'warn',\n message:\n 'Source maps are inlined into your bundles. They are uploaded to Sentry, but inline source maps ship your source code to users and cannot be removed after the upload. ' +\n 'Remove the setting to let the plugin generate hidden source maps instead.',\n },\n };\n\n case 'unset':\n if (deleteOption === false) {\n return {\n enableHidden: true,\n deleteAfterUpload: false,\n log: {\n level: 'info',\n message: 'Enabling hidden source maps. They are uploaded to Sentry and kept in the build output.',\n },\n };\n }\n return {\n enableHidden: true,\n deleteAfterUpload: true,\n removeAllSourceMaps: true,\n log: {\n level: 'info',\n message:\n 'Enabling hidden source maps. They are uploaded to Sentry and removed from the build output. ' +\n 'Set `sourcemaps.deleteSourcemapsAfterUpload: false` to keep them.',\n },\n };\n\n case 'hidden':\n if (deleteOption !== true) {\n return NO_CHANGE;\n }\n return { enableHidden: false, deleteAfterUpload: true, removeAllSourceMaps: sdkEnabledSourceMaps };\n\n case 'visible':\n if (deleteOption !== true) {\n return NO_CHANGE;\n }\n return {\n enableHidden: true,\n deleteAfterUpload: true,\n removeAllSourceMaps: sdkEnabledSourceMaps,\n log: {\n level: 'info',\n message:\n 'Switching to hidden source maps because `sourcemaps.deleteSourcemapsAfterUpload` is set. ' +\n 'Without the `sourceMappingURL` comment browsers do not request the removed map files.',\n },\n };\n }\n}\n"],"mappings":";AA0BA,MAAM,YAA+B;CAAE,cAAc;CAAO,mBAAmB;AAAM;;AAGrF,SAAgB,+BAA+B,SAA4B,aAA2C;CACpH,MAAM,QAAQ,QAAQ,YAAY;CAClC,OAAO,OAAO,UAAU,aAAa,MAAM,WAAW,IAAI;AAC5D;;AAGA,SAAgB,wBAAwB,SAA4B,aAA+B;CACjG,MAAM,QAAQ,QAAQ,YAAY;CAClC,QAAQ,OAAO,UAAU,aAAa,MAAM,WAAW,IAAI,WAAW;AACxE;;;;;;AAOA,SAAgB,wBACd,MACA,SACA,gBACA,aACmB;CACnB,MAAM,eAAe,+BAA+B,SAAS,WAAW;CACxE,MAAM,uBAAuB,wBAAwB,SAAS,WAAW;CAEzE,IAAI,CAAC,kBAAkB,QAAQ,YAAY,SAAS;EAClD,IAAI,iBAAiB,QAAS,SAAS,YAAY,SAAS,WAC1D,OAAO;EAIT,IAAI,QAAQ,YAAY,WAAW,CAAC,sBAClC,OAAO;GACL,GAAG;GACH,KAAK;IACH,OAAO;IACP,SACE;GACJ;EACF;EAEF,OAAO;GACL,cAAc,SAAS;GACvB,mBAAmB;GACnB,qBAAqB;GACrB,KAAK;IACH,OAAO;IACP,SACE;GACJ;EACF;CACF;CAEA,QAAQ,MAAR;EACE,KAAK,OACH,OAAO;GACL,GAAG;GACH,KAAK;IACH,OAAO;IACP,SACE;GAEJ;EACF;EAEF,KAAK,UACH,OAAO;GACL,GAAG;GACH,KAAK;IACH,OAAO;IACP,SACE;GAEJ;EACF;EAEF,KAAK;GACH,IAAI,iBAAiB,OACnB,OAAO;IACL,cAAc;IACd,mBAAmB;IACnB,KAAK;KACH,OAAO;KACP,SAAS;IACX;GACF;GAEF,OAAO;IACL,cAAc;IACd,mBAAmB;IACnB,qBAAqB;IACrB,KAAK;KACH,OAAO;KACP,SACE;IAEJ;GACF;EAEF,KAAK;GACH,IAAI,iBAAiB,MACnB,OAAO;GAET,OAAO;IAAE,cAAc;IAAO,mBAAmB;IAAM,qBAAqB;GAAqB;EAEnG,KAAK;GACH,IAAI,iBAAiB,MACnB,OAAO;GAET,OAAO;IACL,cAAc;IACd,mBAAmB;IACnB,qBAAqB;IACrB,KAAK;KACH,OAAO;KACP,SACE;IAEJ;GACF;CACJ;AACF"}
@@ -0,0 +1,52 @@
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.js");
2
+ let path = require("path");
3
+ path = require_runtime.__toESM(path);
4
+ let glob = require("glob");
5
+ // src/core/upload-filter.ts
6
+ /**
7
+ * Mirrors the glob of the upload from disk for files that are not on disk yet: a file is
8
+ * uploaded when it matches one of `sourcemaps.assets` (all files when unset) and none of
9
+ * `sourcemaps.ignore`.
10
+ */
11
+ function createUploadFilter(options) {
12
+ const cwd = process.cwd();
13
+ const assets = options.sourcemaps?.assets;
14
+ const matchesAssets = assets === void 0 ? () => true : createMatcher(toArray(assets).map((pattern) => toAbsolutePattern(cwd, pattern)), {
15
+ cwd,
16
+ dot: false
17
+ });
18
+ const ignore = toArray(options.sourcemaps?.ignore ?? []);
19
+ const matchesIgnore = ignore.length === 0 ? () => false : createMatcher(ignore, {
20
+ cwd,
21
+ dot: true
22
+ });
23
+ return (filePath) => matchesAssets(filePath) && !matchesIgnore(filePath);
24
+ }
25
+ function createMatcher(patterns, { cwd, dot }) {
26
+ const matcher = new glob.Ignore([], { nocase: process.platform === "darwin" || process.platform === "win32" });
27
+ matcher.mmopts.dot = dot;
28
+ for (const pattern of patterns) matcher.add(pattern);
29
+ return (filePath) => {
30
+ const fullpath = path.resolve(cwd, filePath);
31
+ const relative = toGlobRelativePath(cwd, fullpath);
32
+ return matcher.ignored({
33
+ fullpath: () => fullpath,
34
+ relative: () => relative
35
+ });
36
+ };
37
+ }
38
+ function toAbsolutePattern(cwd, pattern) {
39
+ return path.isAbsolute(pattern) ? pattern : `${(0, glob.escape)(cwd.split(path.sep).join("/"))}/${pattern}`;
40
+ }
41
+ function toGlobRelativePath(cwd, fullpath) {
42
+ const relative = path.relative(cwd, fullpath);
43
+ const levelsUp = relative.split(path.sep).filter((part) => part === "..").length;
44
+ const sharedFolder = path.resolve(cwd, ...new Array(levelsUp).fill(".."));
45
+ return levelsUp > 0 && sharedFolder === path.parse(cwd).root ? fullpath : relative;
46
+ }
47
+ function toArray(patterns) {
48
+ return Array.isArray(patterns) ? patterns : [patterns];
49
+ }
50
+ exports.createUploadFilter = createUploadFilter;
51
+
52
+ //# sourceMappingURL=upload-filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload-filter.js","names":["Ignore","escapeGlob"],"sources":["../../../src/core/upload-filter.ts"],"sourcesContent":["import * as path from 'path';\nimport { escape as escapeGlob, Ignore } from 'glob';\nimport type { NormalizedOptions } from './options-mapping';\n\nexport type UploadFilter = (filePath: string) => boolean;\n\n/**\n * Mirrors the glob of the upload from disk for files that are not on disk yet: a file is\n * uploaded when it matches one of `sourcemaps.assets` (all files when unset) and none of\n * `sourcemaps.ignore`.\n */\nexport function createUploadFilter(options: NormalizedOptions): UploadFilter {\n const cwd = process.cwd();\n\n const assets = options.sourcemaps?.assets;\n // `glob` walks `assets` from the working directory, so a relative pattern is tested against\n // the full path. It skips dot files and folders unless a pattern names them.\n const matchesAssets =\n assets === undefined\n ? () => true\n : createMatcher(\n toArray(assets).map(pattern => toAbsolutePattern(cwd, pattern)),\n { cwd, dot: false },\n );\n\n // `glob` tests `ignore` against the path relative to the working directory, and it matches\n // dot files and folders.\n const ignore = toArray(options.sourcemaps?.ignore ?? []);\n const matchesIgnore = ignore.length === 0 ? () => false : createMatcher(ignore, { cwd, dot: true });\n\n return filePath => matchesAssets(filePath) && !matchesIgnore(filePath);\n}\n\n// `glob` exports the matcher behind its `ignore` option, so both options follow the rules of\n// the upload from disk.\nfunction createMatcher(patterns: string[], { cwd, dot }: { cwd: string; dot: boolean }): UploadFilter {\n const matcher = new Ignore([], { nocase: process.platform === 'darwin' || process.platform === 'win32' });\n // `Ignore` always parses in `dot: true` mode, so the option is set before the patterns are added.\n matcher.mmopts.dot = dot;\n for (const pattern of patterns) {\n matcher.add(pattern);\n }\n return filePath => {\n const fullpath = path.resolve(cwd, filePath);\n const relative = toGlobRelativePath(cwd, fullpath);\n return matcher.ignored({ fullpath: () => fullpath, relative: () => relative } as Parameters<Ignore['ignored']>[0]);\n };\n}\n\nfunction toAbsolutePattern(cwd: string, pattern: string): string {\n return path.isAbsolute(pattern) ? pattern : `${escapeGlob(cwd.split(path.sep).join('/'))}/${pattern}`;\n}\n\n// Like path-scurry: a file outside the working directory gets a `../` path, unless the two\n// share only the file system root. Then it keeps its full path.\nfunction toGlobRelativePath(cwd: string, fullpath: string): string {\n const relative = path.relative(cwd, fullpath);\n const levelsUp = relative.split(path.sep).filter(part => part === '..').length;\n const sharedFolder = path.resolve(cwd, ...new Array<string>(levelsUp).fill('..'));\n return levelsUp > 0 && sharedFolder === path.parse(cwd).root ? fullpath : relative;\n}\n\nfunction toArray(patterns: string | string[]): string[] {\n return Array.isArray(patterns) ? patterns : [patterns];\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,mBAAmB,SAA0C;CAC3E,MAAM,MAAM,QAAQ,IAAI;CAExB,MAAM,SAAS,QAAQ,YAAY;CAGnC,MAAM,gBACJ,WAAW,KAA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