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

Doesn't work with non-node runtimes #3017

Open
cdmistman opened this issue Jun 8, 2023 · 5 comments
Open

Doesn't work with non-node runtimes #3017

cdmistman opened this issue Jun 8, 2023 · 5 comments
Labels
help-wanted Not something we plan on doing, but we will take a pull request.

Comments

@cdmistman
Copy link

Summary

In a bun project, I don't have node available in the environment (as I'm using nix to manage my developer environment). This extension seems to invoke the prettier bin directly, which results in the binary failing to run due to the shebang line #!/usr/bin/env node. While prettier should be runtime-agnostic (but understandably probably can't fix this), there should be a setting in the extension that allows you to override the runtime used to run prettier eg bun ./node_modules/.bin/prettier.

Github Repository to Reproduce Issue

https://github.com/cdmistman/bun-plugin-svelte

Steps To Reproduce:

  1. Initialize a Bun project using bun init
  2. bun add prettier -d
  3. Make .prettierrc file
  4. Make some changes to index.ts that violate your .prettierrc
  5. Run this extension's formatter

Expected result

The file is formatted

Actual result

The file is not formatted

Additional information

Feel free to attach a screenshot.

VS Code Version:

1.78

Prettier Extension Version:

9.13.0

OS and version:

MacOS 13.1

Prettier Log Output

["INFO" - 11:47:12 AM] Extension Name: esbenp.prettier-vscode.
["INFO" - 11:47:12 AM] Extension Version: 9.13.0.

@ghost

This comment was marked as off-topic.

@ziimakc

This comment was marked as off-topic.

@ntotten ntotten added the help-wanted Not something we plan on doing, but we will take a pull request. label Jun 19, 2023
izaakschroeder added a commit to izaakschroeder/prettier-vscode that referenced this issue Jul 3, 2023
Adds a `prettier.runtime` configuration option that, when used, invokes a version of `PrettierWorkerInstance` that uses `fork` instead of worker threads.

Fixes: prettier#3017
Fixes: prettier#2857
izaakschroeder added a commit to izaakschroeder/prettier-vscode that referenced this issue Jul 3, 2023
Adds a `prettier.runtime` configuration option that, when used, invokes a version of `PrettierWorkerInstance` that uses `fork` instead of worker threads.

Fixes: prettier#3017
Fixes: prettier#2857
@izaakschroeder
Copy link

izaakschroeder commented Jul 3, 2023

@cdmistman #3061 should open the door to this. https://bun.sh/docs/runtime/nodejs-apis claims to be mostly node compatible, but I do not know if they support node's IPC protocol (i.e. can a child process spawned under bun use NODE_CHANNEL_FD sent from upstream?). If they do then this is resolved with #3061; if they don't then you'll have to provide some kind of wrapper that handles this as I think it's probably unlikely this project's maintainers are interested in having to build some custom IPC voodoo just for bun.

According to oven-sh/bun#1424 (comment) this is not yet implemented.

izaakschroeder added a commit to izaakschroeder/prettier-vscode that referenced this issue Jul 3, 2023
Adds a `prettier.runtime` configuration option that, when used, invokes a version of `PrettierWorkerInstance` that uses `fork` instead of worker threads.

Fixes: prettier#3017
Fixes: prettier#2857
@cdmistman
Copy link
Author

cdmistman commented Jul 22, 2023

oven-sh/bun#3620

i'd expect support for this to be released before bun's 1.0 launch

@izaakschroeder
Copy link

Exciting! Up to @ntotten how to proceed with that PR however 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help-wanted Not something we plan on doing, but we will take a pull request.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants