@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.
- package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/assertClassBrand.js +6 -0
- package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/checkPrivateRedeclaration.js +5 -0
- package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldGet2.js +6 -0
- package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldInitSpec.js +6 -0
- package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldSet2.js +6 -0
- package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateMethodInitSpec.js +6 -0
- package/build/cjs/_virtual/_rolldown/runtime.js +22 -0
- package/build/cjs/babel-plugin/component-annotation.js +14 -32
- package/build/cjs/babel-plugin/component-annotation.js.map +1 -1
- package/build/cjs/babel-plugin/constants.js +140 -122
- package/build/cjs/babel-plugin/constants.js.map +1 -1
- package/build/cjs/babel-plugin/experimental.js +204 -307
- package/build/cjs/babel-plugin/experimental.js.map +1 -1
- package/build/cjs/babel-plugin/index.js +315 -437
- package/build/cjs/babel-plugin/index.js.map +1 -1
- package/build/cjs/bun/index.js +81 -117
- package/build/cjs/bun/index.js.map +1 -1
- package/build/cjs/core/build-plugin-manager.js +626 -683
- package/build/cjs/core/build-plugin-manager.js.map +1 -1
- package/build/cjs/core/cli.js +134 -129
- package/build/cjs/core/cli.js.map +1 -1
- package/build/cjs/core/component-annotate-hooks.js +16 -27
- package/build/cjs/core/component-annotate-hooks.js.map +1 -1
- package/build/cjs/core/component-annotation-oxc-ast.js +10 -21
- package/build/cjs/core/component-annotation-oxc-ast.js.map +1 -1
- package/build/cjs/core/component-annotation-oxc-fragments.js +45 -74
- package/build/cjs/core/component-annotation-oxc-fragments.js.map +1 -1
- package/build/cjs/core/component-annotation-oxc-jsx.js +116 -156
- package/build/cjs/core/component-annotation-oxc-jsx.js.map +1 -1
- package/build/cjs/core/component-annotation-oxc-walk.js +62 -123
- package/build/cjs/core/component-annotation-oxc-walk.js.map +1 -1
- package/build/cjs/core/component-annotation-oxc.js +68 -103
- package/build/cjs/core/component-annotation-oxc.js.map +1 -1
- package/build/cjs/core/debug-id-upload.js +223 -234
- package/build/cjs/core/debug-id-upload.js.map +1 -1
- package/build/cjs/core/get-code-injection-position.js +59 -74
- package/build/cjs/core/get-code-injection-position.js.map +1 -1
- package/build/cjs/core/glob.js +9 -7
- package/build/cjs/core/glob.js.map +1 -1
- package/build/cjs/core/index.js +77 -61
- package/build/cjs/core/index.js.map +1 -1
- package/build/cjs/core/logger.js +17 -26
- package/build/cjs/core/logger.js.map +1 -1
- package/build/cjs/core/options-mapping.js +95 -117
- package/build/cjs/core/options-mapping.js.map +1 -1
- package/build/cjs/core/sentry/telemetry.js +90 -105
- package/build/cjs/core/sentry/telemetry.js.map +1 -1
- package/build/cjs/core/sentry/transports.js +92 -99
- package/build/cjs/core/sentry/transports.js.map +1 -1
- package/build/cjs/core/sourcemap-settings.js +98 -61
- package/build/cjs/core/sourcemap-settings.js.map +1 -1
- package/build/cjs/core/upload-filter.js +52 -0
- package/build/cjs/core/upload-filter.js.map +1 -0
- package/build/cjs/core/utils.js +228 -219
- package/build/cjs/core/utils.js.map +1 -1
- package/build/cjs/core/version.js +4 -5
- package/build/cjs/core/version.js.map +1 -1
- package/build/cjs/esbuild/index.js +180 -210
- package/build/cjs/esbuild/index.js.map +1 -1
- package/build/cjs/loader-utils/index.js +5 -10
- package/build/cjs/rollup/debug-id-injection.js +22 -38
- package/build/cjs/rollup/debug-id-injection.js.map +1 -1
- package/build/cjs/rollup/debug-id-stamping.js +14 -24
- package/build/cjs/rollup/debug-id-stamping.js.map +1 -1
- package/build/cjs/rollup/index.js +195 -209
- package/build/cjs/rollup/index.js.map +1 -1
- package/build/cjs/rollup/source-map-handling.js +178 -0
- package/build/cjs/rollup/source-map-handling.js.map +1 -0
- package/build/cjs/vite/index.js +19 -35
- package/build/cjs/vite/index.js.map +1 -1
- package/build/cjs/vite/source-map-hooks.js +116 -0
- package/build/cjs/vite/source-map-hooks.js.map +1 -0
- package/build/cjs/webpack/component-annotation-transform.js +20 -26
- package/build/cjs/webpack/component-annotation-transform.js.map +1 -1
- package/build/cjs/webpack/index.js +277 -234
- package/build/cjs/webpack/index.js.map +1 -1
- package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/assertClassBrand.js +6 -0
- package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/checkPrivateRedeclaration.js +5 -0
- package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldGet2.js +6 -0
- package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldInitSpec.js +6 -0
- package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldSet2.js +6 -0
- package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateMethodInitSpec.js +6 -0
- package/build/esm/_virtual/_rolldown/runtime.js +2 -0
- package/build/esm/babel-plugin/component-annotation.js +13 -29
- package/build/esm/babel-plugin/component-annotation.js.map +1 -1
- package/build/esm/babel-plugin/constants.js +140 -120
- package/build/esm/babel-plugin/constants.js.map +1 -1
- package/build/esm/babel-plugin/experimental.js +204 -305
- package/build/esm/babel-plugin/experimental.js.map +1 -1
- package/build/esm/babel-plugin/index.js +311 -434
- package/build/esm/babel-plugin/index.js.map +1 -1
- package/build/esm/bun/index.js +76 -101
- package/build/esm/bun/index.js.map +1 -1
- package/build/esm/core/build-plugin-manager.js +621 -664
- package/build/esm/core/build-plugin-manager.js.map +1 -1
- package/build/esm/core/cli.js +134 -127
- package/build/esm/core/cli.js.map +1 -1
- package/build/esm/core/component-annotate-hooks.js +16 -25
- package/build/esm/core/component-annotate-hooks.js.map +1 -1
- package/build/esm/core/component-annotation-oxc-ast.js +9 -19
- package/build/esm/core/component-annotation-oxc-ast.js.map +1 -1
- package/build/esm/core/component-annotation-oxc-fragments.js +44 -72
- package/build/esm/core/component-annotation-oxc-fragments.js.map +1 -1
- package/build/esm/core/component-annotation-oxc-jsx.js +115 -154
- package/build/esm/core/component-annotation-oxc-jsx.js.map +1 -1
- package/build/esm/core/component-annotation-oxc-walk.js +61 -121
- package/build/esm/core/component-annotation-oxc-walk.js.map +1 -1
- package/build/esm/core/component-annotation-oxc.js +65 -96
- package/build/esm/core/component-annotation-oxc.js.map +1 -1
- package/build/esm/core/debug-id-upload.js +218 -213
- package/build/esm/core/debug-id-upload.js.map +1 -1
- package/build/esm/core/get-code-injection-position.js +59 -72
- package/build/esm/core/get-code-injection-position.js.map +1 -1
- package/build/esm/core/glob.js +9 -5
- package/build/esm/core/glob.js.map +1 -1
- package/build/esm/core/index.js +62 -47
- package/build/esm/core/index.js.map +1 -1
- package/build/esm/core/logger.js +17 -24
- package/build/esm/core/logger.js.map +1 -1
- package/build/esm/core/options-mapping.js +95 -115
- package/build/esm/core/options-mapping.js.map +1 -1
- package/build/esm/core/sentry/telemetry.js +89 -102
- package/build/esm/core/sentry/telemetry.js.map +1 -1
- package/build/esm/core/sentry/transports.js +90 -83
- package/build/esm/core/sentry/transports.js.map +1 -1
- package/build/esm/core/sourcemap-settings.js +96 -59
- package/build/esm/core/sourcemap-settings.js.map +1 -1
- package/build/esm/core/upload-filter.js +50 -0
- package/build/esm/core/upload-filter.js.map +1 -0
- package/build/esm/core/utils.js +221 -209
- package/build/esm/core/utils.js.map +1 -1
- package/build/esm/core/version.js +4 -3
- package/build/esm/core/version.js.map +1 -1
- package/build/esm/esbuild/index.js +176 -194
- package/build/esm/esbuild/index.js.map +1 -1
- package/build/esm/loader-utils/index.js +4 -3
- package/build/esm/package.json +1 -1
- package/build/esm/rollup/debug-id-injection.js +22 -36
- package/build/esm/rollup/debug-id-injection.js.map +1 -1
- package/build/esm/rollup/debug-id-stamping.js +14 -22
- package/build/esm/rollup/debug-id-stamping.js.map +1 -1
- package/build/esm/rollup/index.js +191 -189
- package/build/esm/rollup/index.js.map +1 -1
- package/build/esm/rollup/source-map-handling.js +173 -0
- package/build/esm/rollup/source-map-handling.js.map +1 -0
- package/build/esm/vite/index.js +19 -32
- package/build/esm/vite/index.js.map +1 -1
- package/build/esm/vite/source-map-hooks.js +114 -0
- package/build/esm/vite/source-map-hooks.js.map +1 -0
- package/build/esm/webpack/component-annotation-transform.js +17 -24
- package/build/esm/webpack/component-annotation-transform.js.map +1 -1
- package/build/esm/webpack/index.js +274 -216
- package/build/esm/webpack/index.js.map +1 -1
- package/build/types/core/build-plugin-manager.d.ts +33 -10
- package/build/types/core/build-plugin-manager.d.ts.map +1 -1
- package/build/types/core/cli.d.ts +6 -1
- package/build/types/core/cli.d.ts.map +1 -1
- package/build/types/core/debug-id-upload.d.ts +7 -4
- package/build/types/core/debug-id-upload.d.ts.map +1 -1
- package/build/types/core/index.d.ts +4 -3
- package/build/types/core/index.d.ts.map +1 -1
- package/build/types/core/options-mapping.d.ts +4 -3
- package/build/types/core/options-mapping.d.ts.map +1 -1
- package/build/types/core/sentry/telemetry.d.ts.map +1 -1
- package/build/types/core/sourcemap-settings.d.ts +10 -1
- package/build/types/core/sourcemap-settings.d.ts.map +1 -1
- package/build/types/core/types.d.ts +32 -1
- package/build/types/core/types.d.ts.map +1 -1
- package/build/types/core/upload-filter.d.ts +9 -0
- package/build/types/core/upload-filter.d.ts.map +1 -0
- package/build/types/core/utils.d.ts +4 -0
- package/build/types/core/utils.d.ts.map +1 -1
- package/build/types/core/version.d.ts +1 -1
- package/build/types/esbuild/index.d.ts +2 -2
- package/build/types/esbuild/index.d.ts.map +1 -1
- package/build/types/rollup/index.d.ts +107 -7
- package/build/types/rollup/index.d.ts.map +1 -1
- package/build/types/rollup/source-map-handling.d.ts +59 -0
- package/build/types/rollup/source-map-handling.d.ts.map +1 -0
- package/build/types/vite/index.d.ts +4 -8
- package/build/types/vite/index.d.ts.map +1 -1
- package/build/types/vite/source-map-hooks.d.ts +45 -0
- package/build/types/vite/source-map-hooks.d.ts.map +1 -0
- package/build/types/webpack/index.d.ts +7 -3
- package/build/types/webpack/index.d.ts.map +1 -1
- package/package.json +33 -38
- package/build/cjs/loader-utils/index.js.map +0 -1
- package/build/esm/loader-utils/index.js.map +0 -1
|
@@ -1,92 +1,99 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { createTransport, suppressTracing } from "@sentry/core";
|
|
3
|
+
import * as https from "node:https";
|
|
4
|
+
import { Readable } from "node:stream";
|
|
5
|
+
import { createGzip } from "node:zlib";
|
|
6
|
+
import { appendFileSync, mkdirSync } from "node:fs";
|
|
7
|
+
// src/core/sentry/transports.ts
|
|
8
|
+
/**
|
|
9
|
+
* This is a simplified version of the Sentry Node SDK's HTTP transport.
|
|
10
|
+
*/
|
|
11
|
+
const GZIP_THRESHOLD = 32768;
|
|
12
|
+
/**
|
|
13
|
+
* Gets a stream from a Uint8Array or string
|
|
14
|
+
* Readable.from is ideal but was added in node.js v12.3.0 and v10.17.0
|
|
15
|
+
*/
|
|
9
16
|
function streamFromBody(body) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
});
|
|
17
|
+
return new Readable({ read() {
|
|
18
|
+
this.push(body);
|
|
19
|
+
this.push(null);
|
|
20
|
+
} });
|
|
16
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates a RequestExecutor to be used with `createTransport`.
|
|
24
|
+
*/
|
|
17
25
|
function createRequestExecutor(options) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
req.on("error", reject);
|
|
55
|
-
body.pipe(req);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
};
|
|
26
|
+
const { hostname, pathname, port, protocol, search } = new URL(options.url);
|
|
27
|
+
return function makeRequest(request) {
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
suppressTracing(() => {
|
|
30
|
+
let body = streamFromBody(request.body);
|
|
31
|
+
const headers = {};
|
|
32
|
+
if (request.body.length > GZIP_THRESHOLD) {
|
|
33
|
+
headers["content-encoding"] = "gzip";
|
|
34
|
+
body = body.pipe(createGzip());
|
|
35
|
+
}
|
|
36
|
+
const req = https.request({
|
|
37
|
+
method: "POST",
|
|
38
|
+
headers,
|
|
39
|
+
hostname,
|
|
40
|
+
path: `${pathname}${search}`,
|
|
41
|
+
port,
|
|
42
|
+
protocol
|
|
43
|
+
}, (res) => {
|
|
44
|
+
res.on("data", () => {});
|
|
45
|
+
res.on("end", () => {});
|
|
46
|
+
res.setEncoding("utf8");
|
|
47
|
+
const retryAfterHeader = res.headers["retry-after"] ?? null;
|
|
48
|
+
const rateLimitsHeader = res.headers["x-sentry-rate-limits"] ?? null;
|
|
49
|
+
resolve({
|
|
50
|
+
statusCode: res.statusCode,
|
|
51
|
+
headers: {
|
|
52
|
+
"retry-after": retryAfterHeader,
|
|
53
|
+
"x-sentry-rate-limits": Array.isArray(rateLimitsHeader) ? rateLimitsHeader[0] || null : rateLimitsHeader
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
req.on("error", reject);
|
|
58
|
+
body.pipe(req);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
};
|
|
59
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Creates a Transport that uses native the native 'http' and 'https' modules to send events to Sentry.
|
|
65
|
+
*/
|
|
60
66
|
function makeNodeTransport(options) {
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
const requestExecutor = createRequestExecutor(options);
|
|
68
|
+
return createTransport(options, requestExecutor);
|
|
63
69
|
}
|
|
70
|
+
/** A transport that can be optionally enabled as a later time than it's
|
|
71
|
+
* creation */
|
|
64
72
|
function makeOptionallyEnabledNodeTransport(shouldSendTelemetry) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
};
|
|
73
|
+
return (nodeTransportOptions) => {
|
|
74
|
+
const nodeTransport = makeNodeTransport(nodeTransportOptions);
|
|
75
|
+
return {
|
|
76
|
+
flush: (timeout) => nodeTransport.flush(timeout),
|
|
77
|
+
send: async (request) => {
|
|
78
|
+
if ("__SENTRY_INTERCEPT_TRANSPORT__" in global && Array.isArray(global.__SENTRY_INTERCEPT_TRANSPORT__)) {
|
|
79
|
+
global.__SENTRY_INTERCEPT_TRANSPORT__.push(request);
|
|
80
|
+
return { statusCode: 200 };
|
|
81
|
+
}
|
|
82
|
+
if (await shouldSendTelemetry) {
|
|
83
|
+
if (process.env["SENTRY_TEST_OUT_DIR"]) {
|
|
84
|
+
const outDir = process.env["SENTRY_TEST_OUT_DIR"];
|
|
85
|
+
mkdirSync(outDir, { recursive: true });
|
|
86
|
+
const path = join(outDir, "sentry-telemetry.json");
|
|
87
|
+
appendFileSync(path, `${JSON.stringify(request)},\n`);
|
|
88
|
+
return { statusCode: 200 };
|
|
89
|
+
}
|
|
90
|
+
return nodeTransport.send(request);
|
|
91
|
+
}
|
|
92
|
+
return { statusCode: 200 };
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
};
|
|
89
96
|
}
|
|
90
|
-
|
|
91
97
|
export { makeOptionallyEnabledNodeTransport };
|
|
92
|
-
|
|
98
|
+
|
|
99
|
+
//# 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"],"
|
|
1
|
+
{"version":3,"file":"transports.js","names":[],"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"],"mappings":";;;;;;;;;;AAkBA,MAAM,iBAAiB;;;;;AAMvB,SAAS,eAAe,MAAqC;CAC3D,OAAO,IAAI,SAAS,EAClB,OAAO;EACL,KAAK,KAAK,IAAI;EACd,KAAK,KAAK,IAAI;CAChB,EACF,C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AAO;KAClD,OAAO,EAAE,YAAY,IAAI;IAC3B;IAEA,IAAI,MAAM,qBAAqB;KAC7B,IAAI,QAAQ,IAAI,wBAAwB;MACtC,MAAM,SAAS,QAAQ,IAAI;MAC3B,UAAU,QAAQ,EAAE,WAAW,KAAK,CAAC;MACrC,MAAM,OAAO,KAAK,QAAQ,uBAAuB;MACjD,eAAe,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,61 +1,98 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
...NO_CHANGE,
|
|
11
|
-
log: {
|
|
12
|
-
level: "warn",
|
|
13
|
-
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."
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
case "inline":
|
|
17
|
-
return {
|
|
18
|
-
...NO_CHANGE,
|
|
19
|
-
log: {
|
|
20
|
-
level: "warn",
|
|
21
|
-
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."
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
case "unset":
|
|
25
|
-
if (deleteOption === false) {
|
|
26
|
-
return {
|
|
27
|
-
enableHidden: true,
|
|
28
|
-
deleteAfterUpload: false,
|
|
29
|
-
log: {
|
|
30
|
-
level: "info",
|
|
31
|
-
message: "Enabling hidden source maps. They are uploaded to Sentry and kept in the build output."
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
enableHidden: true,
|
|
37
|
-
deleteAfterUpload: true,
|
|
38
|
-
log: {
|
|
39
|
-
level: "info",
|
|
40
|
-
message: "Enabling hidden source maps. They are uploaded to Sentry and removed from the build output. Set `sourcemaps.deleteSourcemapsAfterUpload: false` to keep them."
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
case "hidden":
|
|
44
|
-
return { enableHidden: false, deleteAfterUpload: deleteOption === true };
|
|
45
|
-
case "visible":
|
|
46
|
-
if (deleteOption !== true) {
|
|
47
|
-
return NO_CHANGE;
|
|
48
|
-
}
|
|
49
|
-
return {
|
|
50
|
-
enableHidden: true,
|
|
51
|
-
deleteAfterUpload: true,
|
|
52
|
-
log: {
|
|
53
|
-
level: "info",
|
|
54
|
-
message: "Switching to hidden source maps because `sourcemaps.deleteSourcemapsAfterUpload` is set. Without the `sourceMappingURL` comment browsers do not request the removed map files."
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
}
|
|
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;
|
|
58
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
|
+
}
|
|
95
|
+
}
|
|
96
|
+
export { decideSourceMapHandling, getDeleteSourcemapsAfterUpload, getSdkEnabledSourceMaps };
|
|
59
97
|
|
|
60
|
-
|
|
61
|
-
//# sourceMappingURL=sourcemap-settings.js.map
|
|
98
|
+
//# 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
|
|
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,a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
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
import { Ignore, escape } from "glob";
|
|
3
|
+
// src/core/upload-filter.ts
|
|
4
|
+
/**
|
|
5
|
+
* Mirrors the glob of the upload from disk for files that are not on disk yet: a file is
|
|
6
|
+
* uploaded when it matches one of `sourcemaps.assets` (all files when unset) and none of
|
|
7
|
+
* `sourcemaps.ignore`.
|
|
8
|
+
*/
|
|
9
|
+
function createUploadFilter(options) {
|
|
10
|
+
const cwd = process.cwd();
|
|
11
|
+
const assets = options.sourcemaps?.assets;
|
|
12
|
+
const matchesAssets = assets === void 0 ? () => true : createMatcher(toArray(assets).map((pattern) => toAbsolutePattern(cwd, pattern)), {
|
|
13
|
+
cwd,
|
|
14
|
+
dot: false
|
|
15
|
+
});
|
|
16
|
+
const ignore = toArray(options.sourcemaps?.ignore ?? []);
|
|
17
|
+
const matchesIgnore = ignore.length === 0 ? () => false : createMatcher(ignore, {
|
|
18
|
+
cwd,
|
|
19
|
+
dot: true
|
|
20
|
+
});
|
|
21
|
+
return (filePath) => matchesAssets(filePath) && !matchesIgnore(filePath);
|
|
22
|
+
}
|
|
23
|
+
function createMatcher(patterns, { cwd, dot }) {
|
|
24
|
+
const matcher = new Ignore([], { nocase: process.platform === "darwin" || process.platform === "win32" });
|
|
25
|
+
matcher.mmopts.dot = dot;
|
|
26
|
+
for (const pattern of patterns) matcher.add(pattern);
|
|
27
|
+
return (filePath) => {
|
|
28
|
+
const fullpath = path.resolve(cwd, filePath);
|
|
29
|
+
const relative = toGlobRelativePath(cwd, fullpath);
|
|
30
|
+
return matcher.ignored({
|
|
31
|
+
fullpath: () => fullpath,
|
|
32
|
+
relative: () => relative
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function toAbsolutePattern(cwd, pattern) {
|
|
37
|
+
return path.isAbsolute(pattern) ? pattern : `${escape(cwd.split(path.sep).join("/"))}/${pattern}`;
|
|
38
|
+
}
|
|
39
|
+
function toGlobRelativePath(cwd, fullpath) {
|
|
40
|
+
const relative = path.relative(cwd, fullpath);
|
|
41
|
+
const levelsUp = relative.split(path.sep).filter((part) => part === "..").length;
|
|
42
|
+
const sharedFolder = path.resolve(cwd, ...new Array(levelsUp).fill(".."));
|
|
43
|
+
return levelsUp > 0 && sharedFolder === path.parse(cwd).root ? fullpath : relative;
|
|
44
|
+
}
|
|
45
|
+
function toArray(patterns) {
|
|
46
|
+
return Array.isArray(patterns) ? patterns : [patterns];
|
|
47
|
+
}
|
|
48
|
+
export { createUploadFilter };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=upload-filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-filter.js","names":["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,KAAA,UACD,OACN,cACE,QAAQ,MAAM,CAAC,CAAC,KAAI,YAAW,kBAAkB,KAAK,OAAO,CAAC,GAC9D;EAAE;EAAK,KAAK;CAAM,CACpB;CAIN,MAAM,SAAS,QAAQ,QAAQ,YAAY,UAAU,CAAC,CAAC;CACvD,MAAM,gBAAgB,OAAO,WAAW,UAAU,QAAQ,cAAc,QAAQ;EAAE;EAAK,KAAK;CAAK,CAAC;CAElG,QAAO,aAAY,cAAc,QAAQ,KAAK,CAAC,cAAc,QAAQ;AACvE;AAIA,SAAS,cAA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