Skip to content

Conversation

@danielroe
Copy link
Contributor

I think this should be slightly more performant than re-importing every time we call the deduped function.

(though in honesty I'm raising it as otherwise the mocks for next/headers in vitest v3+ fail, which I think is a vitest bug)

@vercel
Copy link

vercel bot commented Sep 25, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
flags-sdk-snippets Ready Ready Preview Comment Sep 25, 2025 1:06pm
shirt-shop Ready Ready Preview Sep 25, 2025 1:06pm


// async import required as turbopack errors in Pages Router
// when next/headers is imported at the top-level
const headersPromise = import('next/headers').then((mod) => mod.headers);
Copy link
Collaborator

@dferber90 dferber90 Oct 13, 2025

Choose a reason for hiding this comment

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

I have not tested, but I believe this would lead to an issue in Pages Router, as we can currently do the following at the top level

const foo = dedupe(() => Math.random())

The next/headers import would originally only happen once foo is called. But with this change we would now cause the import of next/headers even if foo is not called.

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.

3 participants