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

feat(core): support prettier v3 as a formatter #18644

Merged
merged 1 commit into from
Aug 16, 2023

Conversation

Michsior14
Copy link
Contributor

Current Behavior

Nx crashes when used with prettier v3.

Expected Behavior

Nx works with all prettier versions up to the newly released v3.

Related Issue(s)

Fixes #17990

@Michsior14 Michsior14 requested a review from a team as a code owner August 15, 2023 19:36
@vercel
Copy link

vercel bot commented Aug 15, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 15, 2023 9:56pm

Copy link
Member

@AgentEnder AgentEnder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really good start 🎉, I left one nitpick but it will also likely need to be handled inside packages/devkit/src/generators/format-files.ts

packages/nx/src/command-line/format/format.ts Outdated Show resolved Hide resolved
@Michsior14
Copy link
Contributor Author

Michsior14 commented Aug 15, 2023

This is a really good start tada, I left one nitpick but it will also likely need to be handled inside packages/devkit/src/generators/format-files.ts

Not sure about the format-files.ts file. It should be correctly working with import as it is.

@AgentEnder
Copy link
Member

This is a really good start tada, I left one nitpick but it will also likely need to be handled inside packages/devkit/src/generators/format-files.ts

Not sure about the format-files.ts file. It should be correctly working with import as it is.

Hey @Michsior14, typescript will transpile away the dynamic import there, so it would hit the same issue I believe? Could we apply a similar patch there to import prettier.cjs if it is present?

@Michsior14
Copy link
Contributor Author

This is a really good start tada, I left one nitpick but it will also likely need to be handled inside packages/devkit/src/generators/format-files.ts

Not sure about the format-files.ts file. It should be correctly working with import as it is.

Hey @Michsior14, typescript will transpile away the dynamic import there, so it would hit the same issue I believe? Could we apply a similar patch there to import prettier.cjs if it is present?

But this is a dynamic import of a library not a binary, isn't it? AFAIK the lib entry point stays the same.

@AgentEnder
Copy link
Member

Good call, I think you are correct. Thanks for the contribution 🎉

@AgentEnder AgentEnder merged commit 54496e8 into nrwl:master Aug 16, 2023
3 checks passed
@gioragutt
Copy link
Contributor

@AgentEnder someone shared this PR with me (post merge), my comment would have been not to do heuristics about what the binary is, but instead just make use of PackageJson['bin'], that way it wouldn't break regardless of version.

@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

prettier@3+ integration
3 participants