Skip to content

fix(nextjs): add extension alias support for handling ESM libs #31323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ndcunningham
Copy link
Contributor

@ndcunningham ndcunningham commented May 23, 2025

Current Behavior

Currently, if you try to import a ESM lib after you generate a Next.js application it fails to build due to how the module exports export * from './lib/lib8446520.js';.

This has been addressed with webpack and needs to be extended to Next.js.

Expected Behavior

You should work out of the box and you should be able to import a lib defined like: export * from './lib/lib8446520.js';.

Related Issue(s)

Fixes #30714

@ndcunningham ndcunningham self-assigned this May 23, 2025
@ndcunningham ndcunningham requested a review from a team as a code owner May 23, 2025 21:35
@ndcunningham ndcunningham requested a review from xiongemi May 23, 2025 21:35
Copy link

vercel bot commented May 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview May 23, 2025 11:57pm

Copy link

nx-cloud bot commented May 23, 2025

View your CI Pipeline Execution ↗ for commit 5f5760d.

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 13m 20s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 20s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 7s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 6s View ↗
nx documentation ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2025-05-24 00:13:17 UTC

@ndcunningham ndcunningham force-pushed the fix/nextjs-esm-lib-import branch from 9690d47 to a3d1799 Compare May 23, 2025 23:44
@ndcunningham ndcunningham force-pushed the fix/nextjs-esm-lib-import branch from a3d1799 to 5f5760d Compare May 23, 2025 23:55
@gperdomor
Copy link
Contributor

@ndcunningham this fix will also works with turbo?

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.

Problems with Next and internal libs
2 participants