Fix re-export detection for Turbopack compatibility#92
Conversation
…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>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
| @@ -0,0 +1,49 @@ | |||
| import { parseCode, hasExportName } from '../src/utils' | |||
|
|
|||
| describe('repro issue', () => { | |||
aralroca
left a comment
There was a problem hiding this comment.
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>
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 injectedgetInitialPropsinto pages that already had a re-exportedgetServerSidePropsorgetStaticProps, 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