-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Problems with Next and internal libs #30714
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
Comments
Out of curiosity: have you tried rspack? https://github.com/vercel/next.js/blob/canary/examples/with-rspack/next.config.js |
can confirm, I'm running into the same issue |
Any update or workaround for this? 👀 |
@mj-meyer did you find a solution for this?... |
Hi @ndcunningham, did you was able to take a look at this?... At the end also occurs in Next 15.2 too, not in Next 15.3 :( |
Hey, I took a look and the problem here is Next.js by default doesn't support esm libs extensions import as A workaround is to just change your library export from const nextConfig = {
webpack: (config) => {
config.resolve.extensionAlias = {
'.js': ['.js', '.ts', '.tsx'],
};
return config;
},
nx: {
// Set this to true if you would like to use SVGR
// See: https://github.com/gregberge/svgr
svgr: false,
},
}; A fix is coming shortly! |
@ndcunningham there is something else happening... If you create a lib, publish the package, and install the package in a new next app in another Nx workspace or created with The problem is the Removing that line make the library works in external next apps |
@gperdomor can you create a new issue for this so that it can be tracked? |
@ndcunningham this is the new issue #31332 to track the new cases, let me know if you need something else 🙏🏻 |
After looking further into this I think there are two issues related to both Webpack and Turbopack. I think that this issue is related to turbopack as the configuration should be the same as webpack. |
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> 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 <!-- This is the behavior we should expect with the changes in this PR --> 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) <!-- Please link the issue being fixed so it gets closed when this is merged. --> This is also related to our webpack and rspack packages. Changes have also been made to them to ensure consistency across bundlers. Fixes #30714
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> 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 <!-- This is the behavior we should expect with the changes in this PR --> 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) <!-- Please link the issue being fixed so it gets closed when this is merged. --> This is also related to our webpack and rspack packages. Changes have also been made to them to ensure consistency across bundlers. Fixes #30714 (cherry picked from commit ae89efb)
Uh oh!
There was an error while loading. Please reload this page.
Current Behavior
You can't use internal workspace libs in your next apps... The packages are not resolved
Expected Behavior
The apps should works as expected...
GitHub Repo
https://github.com/gperdomor/nx-next-issue
Steps to Reproduce
Update next to latest 15.3.0 version (also in package.json from the app folder)Run the app again and open a page... Make sure that runs with next 15.3.0, if not please remove .next folder and node_modules inside your app folder.Nx Report
Failure Logs
Package Manager Version
npm 11.3.0
Operating System
Additional Information
No response
The text was updated successfully, but these errors were encountered: