Skip to content

refactor: route low-cost next modules through compat re-exports#33622

Merged
lyzno1 merged 3 commits intomainfrom
refactor/next-api-compat-low-cost-modules
Mar 18, 2026
Merged

refactor: route low-cost next modules through compat re-exports#33622
lyzno1 merged 3 commits intomainfrom
refactor/next-api-compat-low-cost-modules

Conversation

@lyzno1
Copy link
Member

@lyzno1 lyzno1 commented Mar 18, 2026

Fixes #33496

Summary

  • add thin @/next re-export modules for next, next/dynamic, next/headers, next/script, and next/server
  • migrate the current low-cost call sites to import through the compatibility layer instead of direct next/* imports
  • extend ESLint restrictions so future imports for these modules stay on the compatibility path

Copilot AI review requested due to automatic review settings March 18, 2026 02:07
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 18, 2026
@github-actions github-actions bot added the web This relates to changes on the web. label Mar 18, 2026
@dosubot dosubot bot added javascript Pull requests that update javascript code refactor labels Mar 18, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request centralizes the import paths for several core Next.js modules, including next, next/dynamic, next/headers, next/script, and next/server, by routing them through a new @/next compatibility layer. This refactoring aims to improve maintainability, provide a single point of control for these dependencies, and future-proof the codebase against potential breaking changes in Next.js APIs. The changes also include updated ESLint rules to ensure adherence to these new import conventions.

Highlights

  • Compatibility Layer Introduction: Introduced a compatibility layer for several Next.js modules by creating new re-export modules under the @/next alias.
  • Import Migration: Migrated numerous existing import statements across the codebase to utilize the newly established @/next compatibility layer for Next.js modules.
  • ESLint Enforcement: Enhanced the ESLint configuration with new rules to restrict direct imports from next and specific next/* modules, thereby enforcing the use of the @/next re-export paths for future development.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

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

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 effectively refactors imports from next/* to a new compatibility layer under @/next. This is a good move for long-term maintainability and makes the codebase less coupled to Next.js specifics. The changes are applied consistently across many files, and the new ESLint rules will help enforce this pattern going forward. I have a couple of suggestions to improve consistency by re-exporting the NextConfig type from the new compatibility layer, which would avoid the need for an eslint-disable comment in next.config.ts.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a small compatibility layer (@/next/*) to re-export selected low-cost Next.js modules, migrates existing call sites to import via that layer, and updates ESLint rules to prevent new direct next* imports for the covered modules.

Changes:

  • Add @/next re-export shims for next, next/dynamic, next/headers, next/script, and next/server.
  • Migrate various modules to import these Next APIs through @/next/* instead of next/*.
  • Extend no-restricted-imports to enforce the compatibility import path going forward.

Reviewed changes

Copilot reviewed 34 out of 34 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
web/proxy.ts Switch NextRequest/NextResponse imports to @/next/server.
web/next/server.ts Add compat re-export for next/server (NextResponse, NextRequest).
web/next/script.ts Add compat re-export for next/script default export.
web/next/index.ts Add compat re-export for next types (currently Viewport).
web/next/headers.ts Add compat re-export for next/headers (cookies, headers).
web/next/dynamic.ts Add compat re-export for next/dynamic default export.
web/next.config.ts Add file-level lint suppression to allow next import under new restrictions.
web/i18n-config/server.ts Route cookies/headers imports through @/next/headers.
web/eslint.config.mjs Enforce compat imports by restricting next/next/* imports for the covered modules.
web/context/modal-context-provider.tsx Switch dynamic import to @/next/dynamic.
web/app/signin/_header.tsx Switch dynamic import to @/next/dynamic.
web/app/repos/[owner]/[repo]/releases/route.ts Switch NextRequest/NextResponse imports to @/next/server.
web/app/layout.tsx Switch Viewport type import to @/next.
web/app/components/workflow/panel/index.tsx Switch dynamic import to @/next/dynamic.
web/app/components/workflow/index.tsx Switch dynamic import to @/next/dynamic.
web/app/components/workflow/header/index.tsx Switch dynamic import to @/next/dynamic.
web/app/components/workflow-app/components/workflow-panel.tsx Switch dynamic import to @/next/dynamic.
web/app/components/workflow-app/components/workflow-children.tsx Switch dynamic import to @/next/dynamic.
web/app/components/rag-pipeline/components/panel/index.tsx Switch dynamic import to @/next/dynamic.
web/app/components/devtools/react-scan/loader.tsx Switch Script import to @/next/script.
web/app/components/devtools/react-grab/loader.tsx Switch Script import to @/next/script.
web/app/components/datasets/documents/create-from-pipeline/data-source/local-file/components/file-list-item.tsx Switch dynamic import to @/next/dynamic.
web/app/components/datasets/create/file-uploader/components/file-list-item.tsx Switch dynamic import to @/next/dynamic.
web/app/components/base/zendesk/index.tsx Switch headers/Script imports to @/next/headers and @/next/script.
web/app/components/base/markdown/streamdown-wrapper.tsx Switch dynamic import to @/next/dynamic.
web/app/components/base/markdown/index.tsx Switch dynamic import to @/next/dynamic.
web/app/components/base/markdown-blocks/code-block.tsx Switch dynamic import to @/next/dynamic.
web/app/components/base/ga/index.tsx Switch headers/Script imports to @/next/headers and @/next/script.
web/app/components/base/file-uploader/dynamic-pdf-preview.tsx Switch dynamic import to @/next/dynamic.
web/app/components/apps/new-app-card.tsx Switch dynamic import to @/next/dynamic.
web/app/components/apps/list.tsx Switch dynamic import to @/next/dynamic.
web/app/components/apps/app-card.tsx Switch dynamic import to @/next/dynamic.
web/app/components/app-sidebar/app-info/app-info-modals.tsx Switch dynamic import to @/next/dynamic.
web/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout-main.tsx Switch dynamic import to @/next/dynamic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings March 18, 2026 02:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a small @/next/* compatibility layer for a subset of Next.js modules and updates existing call sites to route through it, with ESLint restrictions added to prevent future direct imports.

Changes:

  • Added thin re-export modules under web/next/ for next, next/dynamic, next/headers, next/script, and next/server.
  • Migrated current usages to import via @/next/* instead of next/*.
  • Extended ESLint no-restricted-imports rules to enforce the compatibility import path going forward.

Reviewed changes

Copilot reviewed 34 out of 34 changed files in this pull request and generated no comments.

Show a summary per file
File Description
web/proxy.ts Switches NextRequest/NextResponse imports to @/next/server.
web/next/server.ts Adds compat re-export for NextResponse and NextRequest type.
web/next/script.ts Adds compat default re-export for next/script.
web/next/index.ts Adds compat type re-exports for NextConfig/Viewport.
web/next/headers.ts Adds compat re-export for cookies/headers.
web/next/dynamic.ts Adds compat default re-export for next/dynamic.
web/next.config.ts Routes NextConfig type import through @/next.
web/i18n-config/server.ts Routes cookies/headers imports through @/next/headers.
web/eslint.config.mjs Adds/extends import restrictions to enforce @/next/* usage.
web/context/modal-context-provider.tsx Routes dynamic import through @/next/dynamic.
web/app/signin/_header.tsx Routes dynamic import through @/next/dynamic.
web/app/repos/[owner]/[repo]/releases/route.ts Routes NextRequest/NextResponse imports through @/next/server.
web/app/layout.tsx Routes Viewport type import through @/next.
web/app/components/workflow/panel/index.tsx Routes dynamic import through @/next/dynamic.
web/app/components/workflow/index.tsx Routes dynamic import through @/next/dynamic.
web/app/components/workflow/header/index.tsx Routes dynamic import through @/next/dynamic.
web/app/components/workflow-app/components/workflow-panel.tsx Routes dynamic import through @/next/dynamic.
web/app/components/workflow-app/components/workflow-children.tsx Routes dynamic import through @/next/dynamic.
web/app/components/rag-pipeline/components/panel/index.tsx Routes dynamic import through @/next/dynamic.
web/app/components/devtools/react-scan/loader.tsx Routes Script import through @/next/script.
web/app/components/devtools/react-grab/loader.tsx Routes Script import through @/next/script.
web/app/components/datasets/documents/create-from-pipeline/data-source/local-file/components/file-list-item.tsx Routes dynamic import through @/next/dynamic.
web/app/components/datasets/create/file-uploader/components/file-list-item.tsx Routes dynamic import through @/next/dynamic.
web/app/components/base/zendesk/index.tsx Routes headers/Script imports through @/next/headers and @/next/script.
web/app/components/base/markdown/streamdown-wrapper.tsx Routes dynamic import through @/next/dynamic.
web/app/components/base/markdown/index.tsx Routes dynamic import through @/next/dynamic.
web/app/components/base/markdown-blocks/code-block.tsx Routes dynamic import through @/next/dynamic.
web/app/components/base/ga/index.tsx Routes headers/Script imports through @/next/headers and @/next/script.
web/app/components/base/file-uploader/dynamic-pdf-preview.tsx Routes dynamic import through @/next/dynamic.
web/app/components/apps/new-app-card.tsx Routes dynamic import through @/next/dynamic.
web/app/components/apps/list.tsx Routes dynamic import through @/next/dynamic.
web/app/components/apps/app-card.tsx Routes dynamic import through @/next/dynamic.
web/app/components/app-sidebar/app-info/app-info-modals.tsx Routes dynamic import through @/next/dynamic.
web/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout-main.tsx Routes dynamic import through @/next/dynamic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 18, 2026
@lyzno1 lyzno1 merged commit d7f70f3 into main Mar 18, 2026
28 checks passed
@lyzno1 lyzno1 deleted the refactor/next-api-compat-low-cost-modules branch March 18, 2026 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update javascript code lgtm This PR has been approved by a maintainer refactor size:M This PR changes 30-99 lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor/Chore] Add a compatibility layer for the Next API

3 participants