diff --git a/changelog.d/fixes/6720-turbopack-agentskills-warning.md b/changelog.d/fixes/6720-turbopack-agentskills-warning.md new file mode 100644 index 0000000000..aa9fc2e42b --- /dev/null +++ b/changelog.d/fixes/6720-turbopack-agentskills-warning.md @@ -0,0 +1 @@ +- **fix(build):** Turbopack production build emitted an "Overly broad patterns can lead to build performance issues" warning per entry point importing `src/lib/agentSkills/generator.ts` (603 warnings reported on v3.8.46, up from 379 on v3.8.45) ([#6582](https://github.com/diegosouzapw/OmniRoute/issues/6582)) — `generator.ts`'s `outputBase` is built as `path.isAbsolute(outputDir) ? outputDir : path.join(process.cwd(), outputDir)`, where `outputDir` is a runtime function parameter, not a compile-time literal, so Turbopack's build-time file-tracing analyzer can't statically narrow the several dynamic `readdirSync`/`rmSync`/`readFileSync`/`writeFileSync` call sites a few lines below and falls back to a project-wide glob; #6366's commit message claimed to "anchor the base path with a literal" but the shipped code never did. Since this fs access is legitimate and bounded (`skills//SKILL.md`, ~48 known IDs), `next.config.mjs`'s `turbopack.ignoreIssue` (Next.js 16.2+) now suppresses this specific, known-benign diagnostic, mirroring the existing `webpack.ignoreWarnings`/`isNextIntlExtractorDynamicImportWarning` precedent already in the same file for the webpack path. Regression guard: `tests/unit/next-config.test.ts` (asserts the `turbopack.ignoreIssue` rule shape targeting `src/lib/agentSkills/**`). diff --git a/next.config.mjs b/next.config.mjs index 5f1d884f74..ac7197503c 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -116,6 +116,24 @@ const nextConfig = { ...mitmManagerAliasFor(process.env), ...minimalBuildAliases, }, + // src/lib/agentSkills/generator.ts builds its fs base path from a runtime + // `outputDir` parameter (`path.join(process.cwd(), outputDir)`), which is + // NOT a compile-time literal, so Turbopack's build-time file-tracing + // analyzer can't statically narrow the several dynamic readdirSync/rmSync/ + // readFileSync/writeFileSync call sites a few lines below and falls back + // to an "Overly broad patterns... matches N files" warning — once per + // Next.js entry point that imports the module (/api/agent-skills/generate, + // /api/cli-tools/pi-settings). The fs access is legitimate and bounded + // (skills//SKILL.md, ~48 known IDs), so this is a known-benign, + // expected diagnostic — suppress it here rather than fight the analyzer, + // mirroring the isNextIntlExtractorDynamicImportWarning precedent below + // for the webpack path. (#6582) + ignoreIssue: [ + { + path: "**/src/lib/agentSkills/**", + description: /Overly broad patterns can lead to build performance issues/, + }, + ], }, output: "standalone", compress: true, diff --git a/tests/unit/next-config.test.ts b/tests/unit/next-config.test.ts index e3bd946643..29821fa4ec 100644 --- a/tests/unit/next-config.test.ts +++ b/tests/unit/next-config.test.ts @@ -271,6 +271,23 @@ test("next-intl webpack hook preserves caller config and filters known extractor ); }); +test("turbopack.ignoreIssue suppresses the agentSkills over-bundling warning (#6582)", async () => { + // src/lib/agentSkills/generator.ts joins process.cwd() with a runtime + // `outputDir` parameter — not a compile-time literal — so Turbopack's + // file-tracing analyzer can't narrow it and emits an "Overly broad + // patterns..." warning per entry point importing the module. The fs access + // is legitimate and bounded, so it's suppressed via turbopack.ignoreIssue + // rather than fought. This guards the config shape so the suppression rule + // isn't silently dropped in a future edit. + const { default: nextConfig } = await loadNextConfig("ignore-issue"); + const rules = nextConfig.turbopack?.ignoreIssue; + + assert.ok(Array.isArray(rules), "expected turbopack.ignoreIssue to be an array"); + const agentSkillsRule = rules.find((rule) => String(rule.path).includes("agentSkills")); + assert.ok(agentSkillsRule, "expected an ignoreIssue rule targeting src/lib/agentSkills/**"); + assert.match(String(agentSkillsRule.description), /Overly broad patterns/); +}); + test("optimizePackageImports excludes the internal @omniroute/open-sse workspace (build-OOM guard)", async () => { // Regression guard: adding the internal `@omniroute/open-sse` workspace to // optimizePackageImports makes Next.js resolve its entire barrel at build