[AI Improvement] [Task] Upgrade next devDependency from ^14 to ^16 and fix Next.js type imports - #11200
[AI Improvement] [Task] Upgrade next devDependency from ^14 to ^16 and fix Next.js type imports#11200joehan wants to merge 3 commits into
Conversation
… types (b/567662468)
There was a problem hiding this comment.
Code Review
This pull request updates the Next.js framework integration to support Next.js v16, including updates to webpack layers, manifest type definitions, and prerender configurations. The review feedback suggests adding defensive fallbacks (|| []) when mapping page.matchers in utils.ts to prevent runtime errors, and making originalSource optional in the shared EdgeFunctionDefinition matchers to avoid type mismatches with older Next.js versions.
| .flat(), | ||
| ); | ||
| const values = Object.values(middlewareManifest.middleware); | ||
| middlewareMatchers.push(...values.map((page) => page.matchers).flat()); |
There was a problem hiding this comment.
To prevent potential runtime errors if page.matchers is undefined or null, consider adding a defensive fallback || [] before flattening.
| middlewareMatchers.push(...values.map((page) => page.matchers).flat()); | |
| middlewareMatchers.push(...values.map((page) => page.matchers || []).flat()); |
References
- Use strict null checks and handle
undefined/nullexplicitly. (link)
There was a problem hiding this comment.
Fixed in commit 547aa3e: added defensive fallback page.matchers || [] before flattening.
Resolves Buganizer b/567662468
Proposed Improvement
nextfrom^14.1.0to^16.3.7(and associated@next/env,postcss,styled-jsx,sharp).ImagesManifestto accommodate Next 16 additions while ensuringunoptimizedremains typed as boolean.initialExpireSeconds,renderingMode,allowHeader) toPrerenderManifestRouteinstances inindex.tsandtesting/app.ts.MiddlewareManifestV3and localMiddlewareManifestV2ininterfaces.ts, supporting both legacy and Next 16 middleware manifests without dropping backward compatibility.WEBPACK_LAYERSinconstants.tsto align with Next 16 layer types.readonly string[]invalidateLocalesinsrc/frameworks/utils.ts.npm-shrinkwrap.jsonusing npm@11.9 to prevent CI lockfile check discrepancies.Verification
npm run buildpassed cleanly.npm run test:compilepassed with 0 errors.npm run lint:quietpassed with 0 errors.npx mocha 'src/frameworks/next/**/*.spec.ts'passed (92 passing tests).npm@11.9normalization runs.