-
Notifications
You must be signed in to change notification settings - Fork 56
fix(esbuild): Don't use namespace for esbuild proxy resolving #311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
df26a12
a076eba
507cc75
5c24b30
29f39f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,34 +38,42 @@ function esbuildReleaseInjectionPlugin(injectionCode: string): UnpluginOptions { | |
|
|
||
| function esbuildDebugIdInjectionPlugin(): UnpluginOptions { | ||
| const pluginName = "sentry-esbuild-debug-id-injection-plugin"; | ||
| const proxyNamespace = "sentry-debug-id-proxy"; | ||
| const stubNamespace = "sentry-debug-id-stub"; | ||
|
|
||
| return { | ||
| name: pluginName, | ||
|
|
||
| esbuild: { | ||
| setup({ onLoad, onResolve }) { | ||
| onResolve({ filter: /.*/ }, (args) => { | ||
| onResolve({ filter: /.*/, namespace: "file" }, (args) => { | ||
| if (args.kind !== "entry-point") { | ||
| return; | ||
| } | ||
|
|
||
| return { | ||
| pluginName, | ||
| path: args.path, | ||
| namespace: proxyNamespace, | ||
| // needs to be an abs path, otherwise esbuild will complain | ||
| path: path.isAbsolute(args.path) ? args.path : path.join(args.resolveDir, args.path), | ||
| namespace: "file", // passthrough | ||
| pluginData: { | ||
| isProxyResolver: true, | ||
| originalPath: args.path, | ||
| originalResolveDir: args.resolveDir, | ||
| }, | ||
| }; | ||
| }); | ||
|
|
||
| onLoad({ filter: /.*/, namespace: proxyNamespace }, (args) => { | ||
| onLoad({ filter: /.*/, namespace: "file" }, (args) => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also here, do we need
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah this namespace is also unnecessary. I think I defined it because I wanted to be conservative over what files we resolve/load, but thinking about it again, it seems unnecesary. Thanks for questioning this!
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
| if (!(args.pluginData.isProxyResolver as undefined | boolean)) { | ||
| return null; | ||
| } | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
| const originalPath = args.pluginData.originalPath as string; | ||
| // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
| const originalResolveDir = args.pluginData.originalResolveDir as string; | ||
|
|
||
| return { | ||
| loader: "js", | ||
| pluginName, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this? We are just hard-coding
filebelow 😅There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, the namespace filter here is very likely unnecessary since we only want to resolve entrypoints which should only have the "file" namespace anyways (since "file" is the default).
The "passthrough" namespace below is then also unnecessary --> removed in 5c24b30