mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
### What?
Adds a new \`get_compilation_issues\` MCP tool (and the underlying
\`projectGetAllCompilationIssues\` NAPI method) that returns all
compilation issues from all routes in a single call.
**New files:**
- \`crates/next-napi-bindings/src/next_api/project.rs\` —
\`project_get_all_compilation_issues\` NAPI function +
\`get_all_compilation_issues_operation\` /
\`get_all_compilation_issues_inner_operation\` turbo-tasks operations
- \`packages/next/src/server/mcp/tools/get-compilation-issues.ts\` — MCP
tool implementation
-
\`packages/next/src/server/mcp/tools/utils/format-compilation-issues.ts\`
— output formatter
-
\`test/development/mcp-server/mcp-server-get-compilation-issues.test.ts\`
— e2e test
- \`test/development/mcp-server/fixtures/compilation-errors-app/\` —
fixture app with three routes (valid page, missing-module error, syntax
error)
**Modified files:**
- \`packages/next/src/build/swc/generated-native.d.ts\` + \`types.ts\` +
\`index.ts\` — expose the new NAPI method
- \`packages/next/src/server/mcp/get-or-create-mcp-server.ts\` —
register the new tool, accept \`getTurbopackProject\` option
- \`packages/next/src/server/dev/hot-reloader-turbopack.ts\` — pass
\`project\` to MCP middleware
- \`packages/next/src/telemetry/events/build.ts\` — add
\`'mcp/get_compilation_issues'\` to the \`McpToolName\` union
### Why?
The existing MCP tools require a browser session (and thus a specific
route to be rendered) to surface compilation errors.
\`get_compilation_issues\` works without a browser session and covers
all routes proactively — useful for AI coding agents that want to check
for errors across the whole app before trying to render a page.
### How?
**NAPI layer:**
\`project_get_all_compilation_issues\` calls a two-level turbo-tasks
operation pair:
1. \`get_all_compilation_issues_inner_operation\` — iterates all
endpoint groups via \`project.get_all_endpoint_groups(false)\` and calls
\`endpoint_group.module_graphs().as_side_effect()\` on each. This builds
the module graph (resolution + transformation) for every entrypoint
without chunking, emitting, or code generation. Issues are emitted as
turbo-tasks collectables.
2. \`get_all_compilation_issues_operation\` — wraps the inner op in
\`strongly_consistent_catch_collectables\` to harvest
issues/diagnostics/effects, then returns an \`OperationResult\`.
> **Why not \`project.whole_app_module_graphs()\`?**
> \`whole_app_module_graphs()\` calls \`drop_issues()\` in development
mode to prevent every per-route HMR subscription from seeing all global
issues. Calling it here would return zero issues in dev. Per-endpoint
\`module_graphs()\` calls don't have this suppression.
**Output formatting (\`format-compilation-issues.ts\`):**
The raw Turbopack wire types are transformed before being returned to
MCP consumers:
- **StyledString → plain string**: \`title\`, \`description\`, and
\`detail\` are \`StyledString\` union trees (recursive \`{type, value}\`
objects). These are flattened to plain strings —
\`text\`/\`code\`/\`strong\` variants return their \`.value\` directly,
\`line\` joins with \`""\`, \`stack\` joins with \`"\n"\`.
- **ANSI codes stripped**: \`codeFrame\` is a pre-rendered string from
the Rust NAPI layer that contains ANSI terminal colour codes. These are
stripped via \`next/dist/compiled/strip-ansi\`.
- **1-indexed source positions**: Turbopack's \`SourcePos\` is 0-indexed
for both \`line\` and \`column\`. The formatter adds \`+1\` to each so
consumers get the conventional editor-style 1-indexed values.
- **Deduplication**: the same issue can surface from multiple endpoints
during the module graph traversal. Issues are deduplicated by a
\`severity|filePath|title|startLine:startCol\` key.
- **No diagnostics**: Turbopack diagnostics are internal telemetry
(\`EVENT_BUILD_FEATURE_USAGE\` feature-adoption counters). They are not
actionable for the user, so the \`diagnostics\` field is omitted
entirely from the response.
**MCP tool (\`get_compilation_issues\`):**
Calls \`project.getAllCompilationIssues()\`, passes the issues through
\`formatCompilationIssues()\`, and returns \`{ issues: FormattedIssue[]
}\` as JSON. Works without a browser session.
**Test:**
A fixture app with three routes (valid \`app/page.tsx\`,
\`app/missing-module/page.tsx\` importing a non-existent package,
\`app/syntax-error/page.tsx\` with unclosed JSX) is used to verify:
1. The tool returns a result without any browser session
2. Module-not-found errors are detected
3. Syntax errors are detected
4. Issues include \`severity\`, \`title\`, \`filePath\` metadata — all
as plain strings (not StyledString objects)
e2e tests: added —
\`test/development/mcp-server/mcp-server-get-compilation-issues.test.ts\`
---------
Co-authored-by: Tobias Koppers <[email protected]>
Co-authored-by: Claude <[email protected]>
65 lines
2.6 KiB
JavaScript
65 lines
2.6 KiB
JavaScript
import { globalIgnores } from 'eslint/config'
|
|
|
|
export default globalIgnores([
|
|
'**/.*/**/*', // Default of ESLint legacy config
|
|
'**/node_modules',
|
|
'**/.next/**/*',
|
|
'**/_next/**/*',
|
|
'**/.vscode/**/*',
|
|
'**/dist/**/*',
|
|
'e2e-tests/**/*',
|
|
'examples/cms-sanity/sanity.types.ts',
|
|
'examples/with-eslint/**/*',
|
|
'examples/with-typescript-eslint-jest/**/*',
|
|
'examples/with-kea/**/*',
|
|
'examples/with-custom-babel-config/**/*',
|
|
'examples/with-flow/**/*',
|
|
'examples/with-jest/**/*',
|
|
'examples/with-mobx-state-tree/**/*',
|
|
'examples/with-mobx/**/*',
|
|
'packages/next/src/bundles/webpack/packages/*.runtime.js',
|
|
'packages/next/src/bundles/webpack/packages/lazy-compilation-*.js',
|
|
'packages/next/src/compiled/**/*',
|
|
'packages/next/wasm/@next',
|
|
'packages/react-refresh-utils/**/*.js',
|
|
'packages/react-dev-overlay/lib/**/*',
|
|
'**/__tmp__/**/*',
|
|
'.github/actions/next-stats-action/.work',
|
|
'packages/next-codemod/transforms/__testfixtures__/**/*',
|
|
'packages/next-codemod/transforms/__tests__/**/*',
|
|
'packages/next-codemod/bin/__testfixtures__/**/*',
|
|
'packages/next-codemod/**/*.js',
|
|
'packages/next-codemod/**/*.d.ts',
|
|
'packages/next-env/**/*.d.ts',
|
|
'packages/create-next-app/templates/**/*',
|
|
'test/integration/eslint/**/*.js',
|
|
'test/integration/script-loader/**/*.js',
|
|
'test/development/basic/legacy-decorators/**/*.js',
|
|
'test/production/emit-decorator-metadata/**/*.js',
|
|
'!test/**/*.test.*',
|
|
'test/e2e/app-dir/rsc-errors/app/swc/use-client/page.js',
|
|
'**/test-timings.json',
|
|
'crates/**/*',
|
|
'bench/nested-deps/**/*',
|
|
'bench/nested-deps-app-router/**/*',
|
|
'bench/heavy-npm-deps/**/*',
|
|
'packages/next-bundle-analyzer/index.d.ts',
|
|
'examples/with-typescript-graphql/lib/gql/',
|
|
'test/development/basic/hmr/components/parse-error.js',
|
|
'test/development/mcp-server/fixtures/default-template/app/build-error/page.tsx',
|
|
'test/development/mcp-server/fixtures/compilation-errors-app/app/syntax-error/page.tsx',
|
|
'test/production/debug-build-path/fixtures/with-compile-error/app/broken/page.tsx',
|
|
'packages/next-swc/native/index.d.ts',
|
|
'packages/next-swc/docs/assets/**/*',
|
|
'test/e2e/app-dir/server-source-maps/fixtures/default/internal-pkg/sourcemapped.js',
|
|
'test/e2e/app-dir/server-source-maps/fixtures/default/external-pkg/sourcemapped.js',
|
|
'test/development/next-lint-eslint-formatter-compact/**/*.js',
|
|
'test/e2e/app-dir/app-external/app/mixed/import/mixed-mod.mjs',
|
|
'turbopack/crates/*/tests/**/*',
|
|
'turbopack/crates/*/js/src/compiled',
|
|
// Eval fixtures are deliberately imperfect code for agents to fix.
|
|
// EVAL.ts is still linted since it's not part of the fixture.
|
|
'evals/evals/*/**/*',
|
|
'!evals/evals/*/EVAL.ts',
|
|
])
|