-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat(builder): transform node:
imports as needed
#6356
feat(builder): transform node:
imports as needed
#6356
Conversation
node:
imports as needed
node:
imports as neededyarnpkg/builder
for plugins transform node:
imports as needed
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
rebased on master. |
any hope to get this merged soon? |
yarnpkg/builder
for plugins transform node:
imports as needednode:
imports as needed
Thanks for the PR, sorry it took so long to get it landed. |
I am happy seeing this merged, and looking forward to having this available with the next release badge. |
Yay 🎉 |
I've created a new release so it should be available now. |
yes, the changes are included in v4.2.0 🚀 |
What's the problem this PR addresses?
Yarn plugins used to be forbidden to import/require built-in modules prefixed with
node:
.see #6135
see #5417
Fixes #5637
The yarn plugin builder should be aware of this fact and produce bundled code, that does not contain any
node:
prefixed import/require.This is especially important when building plugins with 3rd party dependencies, where the plugin author cannot "fix" the imports to yarn's needs.
How did you fix it?
I enabled the plugin-compiler to generate the plugin-code as needed:
I utilized the capability of
esbuild
to strip thesenode:
prefixes from import/require instructions.Therefore, I added config options to the plugin build process to instruct
esbuild
to do so.This is a fix of the plugin builder, which enables plugin authors to compile their work in a backwards-compatible way, so that the build result is runnable in old/unpatched versions of yarn. Unpatched regarding #5997
Related
The #5997 tries to address the issue from the plugin-runtime side.
This would enable "broken" plugins to be runnable in all future/patched versions of yarn-core.
Additionally
This very PR aims to enable plugin authors to create plugins that are runnable with unpatched versions of yarn-core.
It is considered a friction-free backwards-compatible solution on all ends. Yet it does not replace #5997.
Checklist