next.js
adcac5df - Add turbopackIgnoreIssue config to suppress Turbopack warnings (#89682)

Commit
62 days ago
Add turbopackIgnoreIssue config to suppress Turbopack warnings (#89682) ## What? Adds the `experimental.turbopackIgnoreIssue` configuration option, which allows developers to suppress specific Turbopack warnings and errors based on file path, issue title, and/or description patterns. Filtered issues are hidden from both CLI output and the error overlay. ## Why? Developers need a way to suppress noisy or expected warnings from Turbopack without disabling all warnings. This is useful for: - Suppressing warnings from third-party code, generated files, or optional dependencies - Reducing noise in development server output - Hiding expected issues from the error overlay ## How? ### Configuration → Filtering Pipeline 1. **Config types** (`packages/next/src/server/config-shared.ts`, `config-schema.ts`): Each rule has a required `path` (glob string or RegExp) and optional `title`/`description` (exact string or RegExp). All specified fields must match (AND logic). 2. **RegExp serialization** (`packages/next/src/build/swc/index.ts`): Converts RegExp objects to `{ source, flags }` and glob strings to `{ type: 'glob', value }` for transfer to Rust. 3. **Rust deserialization** (`crates/next-core/src/next_config.rs`): `TurbopackIgnoreIssueRule`, `TurbopackIgnoreIssuePathPattern`, and `TurbopackIgnoreIssueTextPattern` types deserialize the config. A `turbopack_ignore_issue_rules()` turbo-tasks function converts them to `IgnoreIssue` rules with proper cache invalidation. 4. **Issue filtering** (`turbopack/crates/turbopack-core/src/issue/mod.rs`): `IssueFilter` is a turbo-tasks value that holds both severity filters and ignore rules. `IgnoreIssuePattern` supports exact string, glob, and regex matching (using `turbo-esregex` for ES-style regex). Matching issues are excluded before severity filtering. 5. **Integration** (`crates/next-api/src/project.rs`, `route.rs`, `empty.rs`): `Endpoint::project()` trait method provides access to the project config. `issue_filter()` builds the `IssueFilter` from project config. All issue collection points use the project's dynamic filter instead of the previous hardcoded `NEXT_ISSUE_FILTER`. ### Documentation - New docs page: `docs/01-app/03-api-reference/05-config/01-next-config-js/turbopackIgnoreIssue.mdx` - Updated Turbopack reference page with experimental options table: `docs/01-app/03-api-reference/08-turbopack.mdx` ### Testing E2E test suite (`test/development/app-dir/turbopack-ignore-issue/`): - **With config**: verifies matching warnings are suppressed from CLI output, matching errors are suppressed from the error overlay, and unrelated pages still compile normally - **Without config**: verifies warnings and errors appear when no rules are defined ### Dependencies - Added `turbo-esregex` for ES-style regex support in Rust ## Example ```js // next.config.js module.exports = { experimental: { turbopackIgnoreIssue: [ { path: '**/vendor/**' }, { path: 'app/**', title: 'Module not found' }, { path: /generated\/.*\.ts/, description: /expected error/i }, ], }, } ```
Author
Parents
Loading