refactor(language_server): Add formatter and linter features#15767
Conversation
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. |
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the language server to make the formatter and linter features optional and independently configurable, allowing for smaller binary sizes and more flexible compilation options.
- Added Cargo feature flags for
formatterandlinterwith both enabled by default - Made
oxc_formatterandoxc_linteroptional dependencies - Added conditional compilation gates throughout the codebase for feature-specific code
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/oxc_language_server/src/main.rs | Updated to conditionally push tools based on enabled features |
| crates/oxc_language_server/src/lib.rs | Added feature gates for formatter and linter module declarations and exports |
| crates/oxc_language_server/Cargo.toml | Made formatter and linter dependencies optional and defined corresponding features with both in default |
| apps/oxlint/Cargo.toml | Explicitly enabled the linter feature for oxc_language_server dependency |
| Cargo.toml | Set default-features = false for workspace-level oxc_language_server dependency to allow consumers to opt-in to features |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
39ff395 to
1b35906
Compare
|
We have #15738 down the road. |
Sysix
left a comment
There was a problem hiding this comment.
oh here are the features flags :)
Merge activity
|
Currently, there is 2 ways to start LS for oxc apps. - `oxc_language_server` - `oxlint --lsp` - (`oxfmt --lsp` will be added soon) Having duplicates are fine for now, but `ServerFormatter` (and `oxc_formatter`) should not bundled in `oxlint --lsp` case. This PR adds `linter` and `formatter` features to exclude. For `oxc_language_server`, both features are enabled by default, keep it as-is.
1b35906 to
03e8f28
Compare
Support `--lsp`, fixes #15739 - Implementation still lives in `oxc_language_server` - The same as `oxlint --lsp` - But now we can remove `oxc_language_server`'s `bin` - For Rust CLI, `.await` with `tokio` - For JS CLI, `napi-rs` automatically wraps with `tokio` --- Now I'm seeing 2 problems: - For JS CLI, `node ./dist/cli.js --lsp` does not work - Instead of waiting LSP message, just panics with error - `{"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error"},"id":null}` - `import process2 from "process";` in bundled file makes this happen, but I don't know why - 👉🏻 Fixed by import `prettier` lazily... - `oxc_linter` is also bundled with `oxfmt` - via `oxc_language_server` - 👉🏻 #15767
Currently, there is 2 ways to start LS for oxc apps. - `oxc_language_server` - `oxlint --lsp` - (`oxfmt --lsp` will be added soon) Having duplicates are fine for now, but `ServerFormatter` (and `oxc_formatter`) should not bundled in `oxlint --lsp` case. This PR adds `linter` and `formatter` features to exclude. For `oxc_language_server`, both features are enabled by default, keep it as-is.
03e8f28 to
f1c62b9
Compare
Support `--lsp`, fixes #15739 - Implementation still lives in `oxc_language_server` - The same as `oxlint --lsp` - But now we can remove `oxc_language_server`'s `bin` - For Rust CLI, `.await` with `tokio` - For JS CLI, `napi-rs` automatically wraps with `tokio` --- Now I'm seeing 2 problems: - For JS CLI, `node ./dist/cli.js --lsp` does not work - Instead of waiting LSP message, just panics with error - `{"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error"},"id":null}` - `import process2 from "process";` in bundled file makes this happen, but I don't know why - 👉🏻 Fixed by import `prettier` lazily... - `oxc_linter` is also bundled with `oxfmt` - via `oxc_language_server` - 👉🏻 #15767
…ject#15767) Currently, there is 2 ways to start LS for oxc apps. - `oxc_language_server` - `oxlint --lsp` - (`oxfmt --lsp` will be added soon) Having duplicates are fine for now, but `ServerFormatter` (and `oxc_formatter`) should not bundled in `oxlint --lsp` case. This PR adds `linter` and `formatter` features to exclude. For `oxc_language_server`, both features are enabled by default, keep it as-is.
Support `--lsp`, fixes oxc-project#15739 - Implementation still lives in `oxc_language_server` - The same as `oxlint --lsp` - But now we can remove `oxc_language_server`'s `bin` - For Rust CLI, `.await` with `tokio` - For JS CLI, `napi-rs` automatically wraps with `tokio` --- Now I'm seeing 2 problems: - For JS CLI, `node ./dist/cli.js --lsp` does not work - Instead of waiting LSP message, just panics with error - `{"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error"},"id":null}` - `import process2 from "process";` in bundled file makes this happen, but I don't know why - 👉🏻 Fixed by import `prettier` lazily... - `oxc_linter` is also bundled with `oxfmt` - via `oxc_language_server` - 👉🏻 oxc-project#15767

Currently, there is 2 ways to start LS for oxc apps.
oxc_language_serveroxlint --lspoxfmt --lspwill be added soon)Having duplicates are fine for now, but
ServerFormatter(andoxc_formatter) should not bundled inoxlint --lspcase.This PR adds
linterandformatterfeatures to exclude.For
oxc_language_server, both features are enabled by default, keep it as-is.