feat: put server, import and lsp behind cargo features#369
Conversation
Review: feat: put server, import and lsp behind cargo featuresNice work overall — the split of Possible bug / stray test artifact
Concretely: Suggest:
Things that look solid on inspection
Minor
Didn't run a local build in this environment (sandboxed), so I relied on static review of the diff plus grepping for stale references — worth having CI actually confirm the no-default-features/test suite passes clean before merge, per this repo's own pre-PR checklist. |
|
Housekeeping: the That means the two touch the same
This PR still needs |
src/server/ held both the axum HTTP layer and the rendering layer (askama templates, view-model builders, i18n, embedded static assets). cook build depends on the latter, so the two could not be gated apart. Move rendering to src/web/ and lift the sync client to src/sync/ (login and logout need it without the server). src/server/ now holds only the axum layer, which lets the next commit put it behind a feature. Pure code movement: no behaviour change.
cargo install cookcli compiles 412 crates on aarch64. A user who only wants cook recipe and cook shopping-list still paid for an HTTP server, a TLS stack, an HTML scraper and a language server, because only self-update and sync were gated. Gate server, import and lsp, and move reqwest under the features that actually use it (import, sync, self-update). All stay on by default, so cargo install is unchanged; --no-default-features now yields a lean CLI: 412 -> 225 crates, 23 MB -> 9 MB. sync implies server, since the sync loop only ever runs inside it. Also pin cooklang's bundled_units explicitly. It was reaching us only through feature unification from cooklang-language-server and cooklang-reports, so gating those off silently changed cook recipe's unit handling (scalable quantities, unit normalisation). Now it is declared where it is used and output is identical in every combination. Refs #366
|
Rebased onto Changes since the last review pass:
Re-verified against the same toolchain CI uses (1.97), not just my local one:
|
083d80c to
e73421b
Compare
ReviewNice piece of work — the Bug:
|
Addresses the dependency-count half of #366.
Why
cargo install cookclicompiles 412 crates on aarch64. Onlyself-updateandsyncwere gated, so someone who wantscook recipeandcook shopping-liststill compiled an HTTP server, a TLS stack, an HTML scraper and a language server.Result
Defaults are unchanged —
cargo install cookclistill gets every command, so this is not a breaking change.--no-default-features--no-default-features --features serverAlways compiled: parsing, scaling, shopping lists, search, pantry, reports,
cook build, seed.Two things worth reviewing carefully
1.
src/server/had to be split first (separate commit, pure code movement). It held both the axum layer and the rendering layer — askama templates, view-model builders, i18n, embedded static assets — andcook builddepends on the latter. They could not be gated apart, so rendering moved tosrc/web/and the sync client tosrc/sync/(login and logout need it without the server).find_todays_menumoved out of an axum handler module intoweb, since it is a pure function returning a template type.2. This surfaced a latent bug. The
bundled_unitsfeature ofcooklang— the unit database behind quantity scaling and unit normalisation — was never declared by cookcli. It was arriving purely through Cargo feature unification, becausecooklang-language-serverandcooklang-reportsdepend oncooklangwith default features. Gatinglspoff dropped it, andcook recipeoutput silently changed:"quantity": { - "scalable": false, - "unit": "c", + "scalable": true, + "unit": "cups",Caught by the snapshot tests. Fixed by declaring
bundled_unitsin our owncooklangdependency, where it is actually used. Output is now identical across every feature combination.This was latent on
main: any dependency change that dropped those crates from the graph would have silently altered recipe output.Also:
syncimpliesserver, because the sync loop only ever runs inside the server (start_syncis unreachable fromcook loginandcook logout).Verification
Build, clippy and tests across every combination —
--no-default-features, each feature alone,server,import,lsp,--all-features, and default:cargo build— 0 errors, 0 warnings in all 9 combinationscargo clippy— 0 warnings in all combinationscargo test— 13 suites pass under default,--no-default-features, and--all-featurescargo fmt --check— cleanThe
test_help_outputsnapshot is now gated onserver/import/lsp, since it asserts the full subcommand list.Independent of #367 (thin LTO) and #368 (install docs).
Refs #366