Skip to content

Commit 89518c4

Browse files
committed
Fix formatting
1 parent e70736d commit 89518c4

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

packages/bundler-plugin-core/src/debug-id-upload.ts

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from "fs";
22
import path from "path";
3-
import * as url from "url"
3+
import * as url from "url";
44
import * as util from "util";
55
import { promisify } from "util";
66
import { SentryBuildPluginManager } from "./build-plugin-manager";
@@ -120,12 +120,16 @@ export async function determineSourceMapPathFromBundle(
120120
resolveSourceMapHook: ResolveSourceMapHook | undefined
121121
): Promise<string | undefined> {
122122
const sourceMappingUrlMatch = bundleSource.match(/^\s*\/\/# sourceMappingURL=(.*)$/m);
123-
const sourceMappingUrl = sourceMappingUrlMatch ? sourceMappingUrlMatch[1] as string : undefined;
123+
const sourceMappingUrl = sourceMappingUrlMatch ? (sourceMappingUrlMatch[1] as string) : undefined;
124124

125125
const searchLocations: string[] = [];
126126

127127
if (resolveSourceMapHook) {
128-
logger.debug(`Calling sourcemaps.resolveSourceMap(${JSON.stringify(bundlePath)}, ${JSON.stringify(sourceMappingUrl)})`);
128+
logger.debug(
129+
`Calling sourcemaps.resolveSourceMap(${JSON.stringify(bundlePath)}, ${JSON.stringify(
130+
sourceMappingUrl
131+
)})`
132+
);
129133
const customPath = await resolveSourceMapHook(bundlePath, sourceMappingUrl);
130134
logger.debug(`resolveSourceMap hook returned: ${JSON.stringify(customPath)}`);
131135

@@ -148,19 +152,19 @@ export async function determineSourceMapPathFromBundle(
148152
} else if (parsedUrl) {
149153
// noop, non-file urls don't translate to a local sourcemap file
150154
} else if (path.isAbsolute(sourceMappingUrl)) {
151-
searchLocations.push(path.normalize(sourceMappingUrl))
155+
searchLocations.push(path.normalize(sourceMappingUrl));
152156
} else {
153157
searchLocations.push(path.normalize(path.join(path.dirname(bundlePath), sourceMappingUrl)));
154158
}
155159
}
156160

157161
// 2. try to find source map at path adjacent to chunk source, but with `.map` appended
158-
searchLocations.push(bundlePath + ".map")
162+
searchLocations.push(bundlePath + ".map");
159163

160164
for (const searchLocation of searchLocations) {
161165
try {
162166
await util.promisify(fs.access)(searchLocation);
163-
logger.debug(`Source map found for bundle \`${bundlePath}\`: \`${searchLocation}\``)
167+
logger.debug(`Source map found for bundle \`${bundlePath}\`: \`${searchLocation}\``);
164168
return searchLocation;
165169
} catch (e) {
166170
// noop
@@ -170,9 +174,11 @@ export async function determineSourceMapPathFromBundle(
170174
// This is just a debug message because it can be quite spammy for some frameworks
171175
logger.debug(
172176
`Could not determine source map path for bundle \`${bundlePath}\`` +
173-
` with sourceMappingURL=${sourceMappingUrl === undefined ? "undefined" : `\`${sourceMappingUrl}\``}` +
174-
` - Did you turn on source map generation in your bundler?` +
175-
` (Attempted paths: ${searchLocations.map(e => `\`${e}\``).join(", ")})`
177+
` with sourceMappingURL=${
178+
sourceMappingUrl === undefined ? "undefined" : `\`${sourceMappingUrl}\``
179+
}` +
180+
` - Did you turn on source map generation in your bundler?` +
181+
` (Attempted paths: ${searchLocations.map((e) => `\`${e}\``).join(", ")})`
176182
);
177183
return undefined;
178184
}

packages/bundler-plugin-core/src/types.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,12 @@ export interface Options {
377377
}
378378

379379
// eslint-disable-next-line @typescript-eslint/no-explicit-any
380-
export type RewriteSourcesHook = (source: string, map: any) => string
380+
export type RewriteSourcesHook = (source: string, map: any) => string;
381381

382-
export type ResolveSourceMapHook = (artifactPath: string, sourceMappingUrl: string | undefined) => string | undefined | Promise<string | undefined>
382+
export type ResolveSourceMapHook = (
383+
artifactPath: string,
384+
sourceMappingUrl: string | undefined
385+
) => string | undefined | Promise<string | undefined>;
383386

384387
export interface ModuleMetadata {
385388
// eslint-disable-next-line @typescript-eslint/no-explicit-any

packages/bundler-plugin-core/test/sentry/resolve-source-maps.test.ts

+9-8
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ const separateBundlePath = path.join(fixtureDir, "separate-directory/bundles/ind
1515
const separateSourceMapPath = path.join(fixtureDir, "separate-directory/sourcemaps/index.js.map");
1616
const separateBundleContent = fs.readFileSync(separateBundlePath, "utf-8");
1717

18-
const sourceMapUrl = "https://sourcemaps.example.com/foo/index.js.map"
18+
const sourceMapUrl = "https://sourcemaps.example.com/foo/index.js.map";
1919

2020
function srcMappingUrl(url: string): string {
21-
return `\n//# sourceMappingURL=${url}`
21+
return `\n//# sourceMappingURL=${url}`;
2222
}
2323

2424
describe("Resolve source maps", () => {
@@ -82,7 +82,8 @@ describe("Resolve source maps", () => {
8282
expect(
8383
await determineSourceMapPathFromBundle(
8484
separateBundlePath,
85-
separateBundleContent + srcMappingUrl(path.relative(path.dirname(separateBundlePath), separateSourceMapPath)),
85+
separateBundleContent +
86+
srcMappingUrl(path.relative(path.dirname(separateBundlePath), separateSourceMapPath)),
8687
logger,
8788
undefined
8889
)
@@ -103,7 +104,7 @@ describe("Resolve source maps", () => {
103104
});
104105

105106
it("should pass the correct values to the resolveSourceMap hook", async () => {
106-
const hook = jest.fn(() => separateSourceMapPath)
107+
const hook = jest.fn(() => separateSourceMapPath);
107108
expect(
108109
await determineSourceMapPathFromBundle(
109110
separateBundlePath,
@@ -112,11 +113,11 @@ describe("Resolve source maps", () => {
112113
hook
113114
)
114115
).toEqual(separateSourceMapPath);
115-
expect(hook.mock.calls[0]).toEqual([separateBundlePath, sourceMapUrl])
116+
expect(hook.mock.calls[0]).toEqual([separateBundlePath, sourceMapUrl]);
116117
});
117118

118119
it("should pass the correct values to the resolveSourceMap hook when no sourceMappingURL is present", async () => {
119-
const hook = jest.fn(() => separateSourceMapPath)
120+
const hook = jest.fn(() => separateSourceMapPath);
120121
expect(
121122
await determineSourceMapPathFromBundle(
122123
separateBundlePath,
@@ -125,7 +126,7 @@ describe("Resolve source maps", () => {
125126
hook
126127
)
127128
).toEqual(separateSourceMapPath);
128-
expect(hook.mock.calls[0]).toEqual([separateBundlePath, undefined])
129+
expect(hook.mock.calls[0]).toEqual([separateBundlePath, undefined]);
129130
});
130131

131132
it("should prefer resolveSourceMap result over heuristic results", async () => {
@@ -161,4 +162,4 @@ describe("Resolve source maps", () => {
161162
).toEqual(adjacentSourceMapPath);
162163
});
163164
});
164-
});
165+
});

0 commit comments

Comments
 (0)