feat(oxfmt): use prettier directly and bundle prettier#15544
feat(oxfmt): use prettier directly and bundle prettier#15544graphite-app[bot] merged 1 commit intomainfrom
prettier directly and bundle prettier#15544Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
prettier and @prettier/syncprettier directly and bundle prettier
54d55d3 to
8dcee8c
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR migrates from the synchronous @prettier/sync package to the standard async prettier package for formatting embedded languages (CSS, GraphQL, HTML, Markdown) in template literals.
Key changes:
- Removes the
@prettier/syncdependency in favor of the standard asyncprettierpackage - Updates the TypeScript/JavaScript code to use async/await pattern with Promises
- Modifies the Rust FFI layer to handle Promise return types using
block_onto await promise resolution - Configures bundler to include
prettieras an internal dependency
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Removes @prettier/sync dependency from the lockfile |
| apps/oxfmt/package.json | Removes @prettier/sync from dependencies |
| apps/oxfmt/tsdown.config.ts | Configures bundler to bundle prettier instead of treating it as external |
| apps/oxfmt/src-js/embedded.ts | Converts formatEmbeddedCode from sync to async, returns Promise and uses promise chaining |
| apps/oxfmt/src/run.rs | Changes parameter type from reference to owned Vec to avoid unnecessary allocation |
| apps/oxfmt/src/prettier_plugins/external_formatter.rs | Updates type signatures to handle Promise<String> and uses block_on to await promise resolution |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I think this would be ideal if there were no drawbacks. Let me try, run benchmark locally. |
Merge activity
|
`@prettier/sync` is the synchronous version of `prettier`, which uses the `Worker` to hack it and make it synchronous. Everything worked fine before we wanted to bundle them together. However, it hangs when they are bundled. I haven't found the reason why it hangs. Anyway, I don't think `@prettier/sync` is a good choice because it is not `real` synchronous, which sacrifices some performance to make it available. Note: I am not familiar with NAPI, so I'm not sure whether the API is used correctly.
0dd7326 to
3251000
Compare

@prettier/syncis the synchronous version ofprettier, which uses theWorkerto hack it and make it synchronous.Everything worked fine before we wanted to bundle them together. However, it hangs when they are bundled. I haven't found the reason why it hangs. Anyway, I don't think
@prettier/syncis a good choice because it is notrealsynchronous, which sacrifices some performance to make it available.Note: I am not familiar with NAPI, so I'm not sure whether the API is used correctly.