Skip to content

Commit 68472b5

Browse files
author
Luca Forstner
authored
fix(esbuild): Don't use namespace for esbuild proxy resolving (#311)
1 parent 7bc04dc commit 68472b5

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

packages/esbuild-plugin/src/index.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ function esbuildReleaseInjectionPlugin(injectionCode: string): UnpluginOptions {
3838

3939
function esbuildDebugIdInjectionPlugin(): UnpluginOptions {
4040
const pluginName = "sentry-esbuild-debug-id-injection-plugin";
41-
const proxyNamespace = "sentry-debug-id-proxy";
4241
const stubNamespace = "sentry-debug-id-stub";
4342

4443
return {
@@ -49,23 +48,31 @@ function esbuildDebugIdInjectionPlugin(): UnpluginOptions {
4948
onResolve({ filter: /.*/ }, (args) => {
5049
if (args.kind !== "entry-point") {
5150
return;
51+
} else {
52+
return {
53+
pluginName,
54+
// needs to be an abs path, otherwise esbuild will complain
55+
path: path.isAbsolute(args.path) ? args.path : path.join(args.resolveDir, args.path),
56+
pluginData: {
57+
isProxyResolver: true,
58+
originalPath: args.path,
59+
originalResolveDir: args.resolveDir,
60+
},
61+
};
5262
}
53-
return {
54-
pluginName,
55-
path: args.path,
56-
namespace: proxyNamespace,
57-
pluginData: {
58-
originalPath: args.path,
59-
originalResolveDir: args.resolveDir,
60-
},
61-
};
6263
});
6364

64-
onLoad({ filter: /.*/, namespace: proxyNamespace }, (args) => {
65+
onLoad({ filter: /.*/ }, (args) => {
66+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
67+
if (!(args.pluginData?.isProxyResolver as undefined | boolean)) {
68+
return null;
69+
}
70+
6571
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
6672
const originalPath = args.pluginData.originalPath as string;
6773
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
6874
const originalResolveDir = args.pluginData.originalResolveDir as string;
75+
6976
return {
7077
loader: "js",
7178
pluginName,

0 commit comments

Comments
 (0)