refactor: route low-cost next modules through compat re-exports#33622
refactor: route low-cost next modules through compat re-exports#33622
Conversation
Summary of ChangesHello, 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 Highlights
🧠 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 AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
@/nextre-export shims fornext,next/dynamic,next/headers,next/script, andnext/server. - Migrate various modules to import these Next APIs through
@/next/*instead ofnext/*. - Extend
no-restricted-importsto 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.
There was a problem hiding this comment.
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/fornext,next/dynamic,next/headers,next/script, andnext/server. - Migrated current usages to import via
@/next/*instead ofnext/*. - Extended ESLint
no-restricted-importsrules 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.
Fixes #33496
Summary
@/nextre-export modules fornext,next/dynamic,next/headers,next/script, andnext/servernext/*imports