Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Page re-export leaks server code to browser | GoodFirstPicks

Page re-export leaks server code to browser

vercel/next.js 2 comments 13d ago
View on GitHub
mediumopenScope: somewhat clearSkill match: maybeNext.jsTypeScriptReact

Why this is a good first issue

Server code leaks to browser due to re-exporting pages.

AI Summary

The issue involves server code leaking to the browser when re-exporting pages in the Pages Router, specifically causing module resolution errors. The problem appears to be related to tree-shaking limitations in Next.js. The issue is somewhat clear but requires understanding of Next.js bundling behavior.

Issue Description

Link to the code that reproduces this issue

https://github.com/timheerwagen/re-export-page-server-code-leak

To Reproduce

  1. Install dependencies and start the development server: next dev
  2. The server code for the /index page works.
  3. Navigate to /plugin-page - Server Code leaks to browser (Module not found: Can't resolve 'fs/promises')
  4. Navigate to /component-page - Server Code leaks to browser (Module not found: Can't resolve 'fs/promises')

Current vs. Expected behavior

Only the getServerSideProps function in the pages directory works with server code.

Re-exporting a page, whether within the same application package or an external/workspace package (e.g. plugin), leaks server code to the browser.

The docs state a fix, which has already been used to reproduce the issue: https://nextjs.org/docs/messages/export-all-in-page#possible-ways-to-fix-it (export { default, getServerSideProps } from "@repo/page-plugin/pages/index"; )

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Home
  Available memory (MB): 16294
  Available CPU cores: 12
Binaries:
  Node: 24.11.1
  npm: 11.6.2
  Yarn: N/A
  pnpm: 9.0.0
Relevant Packages:
  next: 16.1.0 // Latest available version is detected (16.1.0).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: N/A
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Pages Router

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

No response

GitHub Labels

Pages Router

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!

Risk Flags

  • tree-shaking limitation
  • specific to Pages Router
Loading labels...

Details

Points20 pts
Difficultymedium
Scopesomewhat clear
Skill Matchmaybe
Test Focusedno