Skip to content

Fix re-export detection for Turbopack compatibility#92

Merged
aralroca merged 2 commits intomainfrom
fix-reexport-detection-turbopack-13189860664831108325
Feb 28, 2026
Merged

Fix re-export detection for Turbopack compatibility#92
aralroca merged 2 commits intomainfrom
fix-reexport-detection-turbopack-13189860664831108325

Conversation

@aralroca
Copy link
Copy Markdown
Owner

Fix re-export detection in next-translate-plugin for Turbopack compatibility.

Improved detection of Next.js data-fetching methods (getStaticProps, etc.) when using star re-exports (export * from '...'). This fixes a conflict where the plugin incorrectly injected getInitialProps into pages that already had a re-exported getServerSideProps or getStaticProps, causing a build error in Next.js. The fix is especially relevant for Turbopack where the data-fetching methods might be re-exported from separate data files.

Fixes #91


PR created automatically by Jules for task 13189860664831108325 started by @aralroca

…ibility.

This change improves how Next.js data-fetching methods (getStaticProps, getServerSideProps, etc.) are detected when they are re-exported using `export * from '...'`. Due to the use of `noResolve: true` in the TypeScript compiler options, these re-exports were previously not detected, leading to incorrect injection of `getInitialProps` and a subsequent Next.js error: "You can not use getInitialProps with getServerSideProps".

A fallback has been added to `hasExportName` in `src/utils.ts` to scan the AST for star re-exports when checking for these specific data-fetching methods. tests have been added to verify this behavior and ensure no regressions for other types of exports.

Co-authored-by: aralroca <13313058+aralroca@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@google-labs-jules google-labs-jules Bot mentioned this pull request Feb 28, 2026
@@ -0,0 +1,49 @@
import { parseCode, hasExportName } from '../src/utils'

describe('repro issue', () => {
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Add the ID of the issue: #91

Copy link
Copy Markdown
Owner Author

@aralroca aralroca left a comment

Choose a reason for hiding this comment

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

Looks good the fallback for the detection

…ibility.

This change improves how Next.js data-fetching methods (getStaticProps, getServerSideProps, etc.) are detected when they are re-exported using `export * from '...'`. Due to the use of `noResolve: true` in the TypeScript compiler options, these re-exports were previously not detected, leading to incorrect injection of `getInitialProps` and a subsequent Next.js error: "You can not use getInitialProps with getServerSideProps".

A fallback has been added to `hasExportName` in `src/utils.ts` to scan the AST for star re-exports when checking for these specific data-fetching methods. tests have been added to verify this behavior and ensure no regressions for other types of exports.

Related with #91

Co-authored-by: aralroca <13313058+aralroca@users.noreply.github.com>
@aralroca aralroca merged commit 2f0a5cc into main Feb 28, 2026
4 checks passed
@aralroca aralroca deleted the fix-reexport-detection-turbopack-13189860664831108325 branch February 28, 2026 07:55
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.

Next 16 and Turbopack

1 participant