Skip to content

[Bug?]: Plugins don't work in 4.1.0 #6135

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

Closed
1 task
alamothe opened this issue Feb 22, 2024 · 2 comments · Fixed by #5997
Closed
1 task

[Bug?]: Plugins don't work in 4.1.0 #6135

alamothe opened this issue Feb 22, 2024 · 2 comments · Fixed by #5997
Labels
bug Something isn't working

Comments

@alamothe
Copy link

alamothe commented Feb 22, 2024

Self-service

  • I'd be willing to implement a fix

Describe the bug

After installing a plugin, when starting yarn it outputs:

Usage Error: This plugin cannot access the package referenced via node:process which is neither a builtin, 
nor an exposed entry (when initializing @yarnpkg/plugin-tools, defined in /.../projects/xyz/.yarnrc.yml)

To reproduce

Any plugin doesn't work, but in particular:

yarn plugin import https://yarn.build/latest

Then:

yarn

Environment

System:
    OS: macOS 14.2.1
    CPU: (12) arm64 Apple M2 Max
  Binaries:
    Node: 18.19.1 - /private/var/folders/dk/wjrhndy12g9b9p2lyfx6qm9c0000gn/T/xfs-e4c1f94a/node
    Yarn: 4.1.0 - /private/var/folders/dk/wjrhndy12g9b9p2lyfx6qm9c0000gn/T/xfs-e4c1f94a/yarn
    npm: 10.2.4 - /opt/homebrew/opt/node@18/bin/npm

Additional context

No response

@alamothe alamothe added the bug Something isn't working label Feb 22, 2024
@alamothe alamothe changed the title [Bug?]: Plugin doesn't work in 4.1.0 [Bug?]: Plugins don't work in 4.1.0 Feb 22, 2024
@adrian-gierakowski
Copy link

related issue: #5637

github-merge-queue bot pushed a commit that referenced this issue Aug 25, 2024
## What's the problem this PR addresses?

<!-- Describe the rationale of your PR. -->
<!-- Link all issues that it closes. (Closes/Resolves #xxxx.) -->

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?

<!-- A detailed description of your implementation. -->

I enabled the plugin-compiler to generate the plugin-code as needed:

I utilized the capability of `esbuild` to strip these `node:` 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

<!--- Don't worry if you miss something, chores are automatically
tested. -->
<!--- This checklist exists to help you remember doing the chores when
you submit a PR. -->
<!--- Put an `x` in all the boxes that apply. -->
- [x] I have read the [Contributing
Guide](https://yarnpkg.com/advanced/contributing).

<!-- See
https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released
for more details. -->
<!-- Check with `yarn version check` and fix with `yarn version check
-i` -->
- [x] I have set the packages that need to be released for my changes to
be effective.

<!-- The "Testing chores" workflow validates that your PR follows our
guidelines. -->
<!-- If it doesn't pass, click on it to see details as to what your PR
might be missing. -->
- [x] I will check that all automated PR checks pass before the PR gets
reviewed.

---------

Signed-off-by: Jan Kowalleck <[email protected]>
Co-authored-by: Maël Nison <[email protected]>
@jkowalleck
Copy link
Contributor

shoud be fixed via #6356
the next version of yarn plugin builder/bundler should include a feature that solves this behavior for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants