next.js
de1add25 - Remove unused turbo-tasks items and add lint check (#90801)

Commit
19 days ago
Remove unused turbo-tasks items and add lint check (#90801) ### What? Adds a lint script (`scripts/check-unused-turbo-tasks.mjs`) that detects unused `#[turbo_tasks::function]`, `#[turbo_tasks::value]`, and `#[turbo_tasks::value_trait]` definitions across the Rust codebase, and removes all currently unused items. ### Why? Dead turbo-tasks definitions add compilation overhead (each generates trait impls, registrations, etc.) and make the codebase harder to navigate. A lint check prevents regressions. ### How? **New script** (`scripts/check-unused-turbo-tasks.mjs`): 1. Discovers all `.rs` files in `turbopack/crates/` and `crates/` (excluding `turbo-tasks-macros-tests`) 2. Parses three kinds of turbo-tasks annotations: - `#[turbo_tasks::function]` → extracts `fn` name + context (free, inherent impl, trait impl, trait default) - `#[turbo_tasks::value]` → extracts `struct`/`enum` name - `#[turbo_tasks::value_trait]` → extracts `trait` name 3. Scans all files for identifier references, excluding definition sites 4. Reports any name that has no external references The script is added to the `pnpm lint` command (runs in parallel with other checks). **Removed 23 unused items** across 18 files: | Kind | Count | Examples | |------|-------|---------| | `value` (struct/enum) | 9 | `OutputAssetsWithAvailability`, `ModuleNameMap`, `OptionModuleIds`, `LockedVersions`, `AssetContentSnapshot` | | `function` | 14 | `client_env`, `next_js_file`, `convert_path`, `is_hot_module_replacement_enabled`, `any_content_changed_of_output_asset` | Also cleaned up imports that became unused after the removals.
Author
Parents
Loading