Consider Formatly instead of a direct Prettier dependency in @react-router/dev #15370
Replies: 2 comments 3 replies
|
I converted this to a discussion because it'a a feature request. I don't think this is necessary since it's only used in a single case ( |
|
This is a great suggestion. Replacing direct runtime dependencies on Prettier in CLI scaffolding tools improves bundle weight and respects the user's preferred toolchain (e.g., Biome, dprint). Here are a few technical considerations for integrating 1. In-Memory Formatting vs. Disk FormattingAs noted, Since
2. Dependency FootprintRemoving 3. Implementation Checklist
Happy to open a PR for this if the maintainers are open to the change! |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
Please consider using Formatly in
@react-router/devinstead of depending directly on Prettier.Motivation
packages/react-router-dev/cli/useJavascript.tscurrently importsprettierand callsprettier.format(...)on JavaScript generated by Babel. As a result,@react-router/devincludes Prettier as a runtime dependency even when the consuming project uses another formatter such as Biome, dprint, ordeno fmt.Formatly is intended for developer tools that generate user-owned files. It detects and invokes the formatter already configured by the project, with support for Biome,
deno fmt, dprint, and Prettier, with Oxfmt support pending in Formatly PR #544.Possible approach
Consider replacing the direct Prettier integration with Formatly so generated JavaScript follows the consuming project's formatter configuration.
The current
transpilefunction returns a formatted string, while Formatly operates on generated files or glob patterns. Integration may therefore involve formatting the generated JavaScript after it is written to disk, or adjusting the surrounding workflow as appropriate.If no supported formatter is configured, React Router could retain the Babel output or otherwise preserve the current fallback behavior.
References
react-router/packages/react-router-dev/cli/useJavascript.ts
Line 29 in 8bc59bc
All reactions