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

fix(esbuild-plugin-pnp): return resolveDir from onLoad #4597

Merged
merged 2 commits into from
Jul 1, 2022

Conversation

alisd23
Copy link
Contributor

@alisd23 alisd23 commented Jul 1, 2022

A fix in the same area as #4569, for the esbuild-plugin-pnp, regarding the resolveDir property

What's the problem this PR addresses?
Many plugins use the resolveDir argument in the onResolve callback (e.g. to find the absolute path of an imported relative module like in the Remix compiler

Currently, plugins that rely on modules loaded with yarn pnp, get an empty resolveDir passed to the onResolve callback.

It would make sense to, when loading modules with pnp, default the resolveDir to the directory of the current module/file being loaded, as it also lives on disk. This brings us closer in behaviour to the default file namespaced modules too.

How did you fix it?
In the default onLoad callback in the esbuild plugin, we can return the directory the file (args.path) being loaded lives in.

Checklist

  • I have read the Contributing Guide.
  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@merceyz merceyz enabled auto-merge (squash) July 1, 2022 22:21
@merceyz merceyz changed the title fix(esbuild-plugin-pnp): return resolveDir from esbuild-pnp-plugin onLoad fix(esbuild-plugin-pnp): return resolveDir from onLoad Jul 1, 2022
@alisd23
Copy link
Contributor Author

alisd23 commented Jul 1, 2022

@merceyz Out of interest, why is esbuild-plugin-pnp still a release candidate? Is there a specific reason, or should we bump to 3.0.0?

@merceyz
Copy link
Member

merceyz commented Jul 1, 2022

The release candidates is how we do "canary" releases, the master branch is currently building up to the next major but it isn't ready yet so this PR, among others, will be backported to a stable release.

@merceyz merceyz merged commit 90d7cac into yarnpkg:master Jul 1, 2022
@alisd23
Copy link
Contributor Author

alisd23 commented Jul 1, 2022

Okay cool, makes sense. Also thanks for the speedy review & merge 👍

@merceyz
Copy link
Member

merceyz commented Jul 1, 2022

No worries and thanks for the fix! I've triggered a new "canary" release so it should be published soon.

@alisd23 alisd23 deleted the fix/esbuild-plugin-resolve-dir-load branch July 1, 2022 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants