Skip to content

[AI Improvement] [Task] Upgrade next devDependency from ^14 to ^16 and fix Next.js type imports - #11200

Draft
joehan wants to merge 3 commits into
mainfrom
ai-improve-567662468-task-upgrade-next-devdependency-fro
Draft

joehan wants to merge 3 commits into
mainfrom
ai-improve-567662468-task-upgrade-next-devdependency-fro

Conversation

@joehan

@joehan joehan commented Sep 29, 2026

Copy link
Copy Markdown
Member

Resolves Buganizer b/567662468

Proposed Improvement

  • Upgrades devDependency next from ^14.1.0 to ^16.3.7 (and associated @next/env, postcss, styled-jsx, sharp).
  • Fixes TypeScript compilation errors resulting from Next.js 16 internal type updates:
    • Widened ImagesManifest to accommodate Next 16 additions while ensuring unoptimized remains typed as boolean.
    • Added required Next 16 fields (initialExpireSeconds, renderingMode, allowHeader) to PrerenderManifestRoute instances in index.ts and testing/app.ts.
    • Added MiddlewareManifestV3 and local MiddlewareManifestV2 in interfaces.ts, supporting both legacy and Next 16 middleware manifests without dropping backward compatibility.
    • Updated WEBPACK_LAYERS in constants.ts to align with Next 16 layer types.
    • Handled readonly string[] in validateLocales in src/frameworks/utils.ts.
  • Normalized npm-shrinkwrap.json using npm@11.9 to prevent CI lockfile check discrepancies.

Verification

  • npm run build passed cleanly.
  • npm run test:compile passed with 0 errors.
  • npm run lint:quiet passed with 0 errors.
  • npx mocha 'src/frameworks/next/**/*.spec.ts' passed (92 passing tests).
  • Confirmed zero drift across repeated npm@11.9 normalization runs.

@joehan joehan self-assigned this Sep 29, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/frameworks/next/utils.ts Outdated
Comment thread src/frameworks/next/utils.ts Outdated
.flat(),
);
const values = Object.values(middlewareManifest.middleware);
middlewareMatchers.push(...values.map((page) => page.matchers).flat());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To prevent potential runtime errors if page.matchers is undefined or null, consider adding a defensive fallback || [] before flattening.

Suggested change
middlewareMatchers.push(...values.map((page) => page.matchers).flat());
middlewareMatchers.push(...values.map((page) => page.matchers || []).flat());
References
  1. Use strict null checks and handle undefined/null explicitly. (link)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, please fix

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 547aa3e: added defensive fallback page.matchers || [] before flattening.

Comment thread src/frameworks/next/interfaces.ts

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants