Skip to content
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

onResolve is not fired on entrypoints when namespace equals 'file' #791

Closed
igoradamenko opened this issue Feb 11, 2021 · 2 comments · Fixed by #1078
Closed

onResolve is not fired on entrypoints when namespace equals 'file' #791

igoradamenko opened this issue Feb 11, 2021 · 2 comments · Fixed by #1078
Labels

Comments

@igoradamenko
Copy link

Hey there!

I was writing a plugin and realized that onResolve is not fired on entrypoints when namespace equals 'file'.

build.onResolve({ filter: /someregexp/, namespace: 'file' }, args => {});

↑ callback here won't be fired on entrypoint JS file.

build.onResolve({ filter: /someregexp/ }, args => {});

↑ callback here will be fired on entrypoint JS file. And args.namespace will be an empty string.

It is probably related to #546, but I'm not sure. Is it a normal thing, or a bug? I want to make sure that my plugin do not process anything not related to it, and have decided to use namespace: 'file'. But I also need to process entrypoints. So right now I have to omit namespace setting in onResolve filtering.

(I can create a small example project to illustrate the behavior.)

@evanw
Copy link
Owner

evanw commented Feb 13, 2021

This is deliberate. The point of plugins is to be able to augment esbuild's behavior and give it new abilities. This includes the ability for a path to mean something else other than a file system path. For example, you might run esbuild with a URL as an entry point and with a plugin that moves paths to the url namespace since they are not file system paths. It seems wrong for esbuild to assume entry points are file system paths when that may not be the case.

I could potentially change this assumption to force entry points to be treated as file system paths. However, that would be a breaking change so it would have to wait until the next breaking change release.

@igoradamenko
Copy link
Author

🤔

This makes sense, thanks. But isn't it possible to determine what the entrypoint is when esbuild starts to resolve its path? I mean, when it is received a URL as an entrypoint, it starts to process them in url namespace, etc. Otherwise, why are the nested modules treated as being in file namespace? Isn't it depends only on the format of the imported path?

(Anyway, sure, the possible change of the current behavior should be breaking change, I'm not forcing to release any changes. Just want to understand the logic behind the scenes.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants