-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
On nx 15.8.7 can't build Next app (13.1.6 nor 13.2.4) #15794
Comments
Having the same challenge on my end. Been trying to reproduce it in a fresh application. Noted my details here on #15214 (comment) |
When will this issue be resolved? This issue is very critical and is impacting our development. |
We have used Nx in our organization for roughly a year. The ongoing issues with Next.js honestly have us reconsidering if Nx is the right choice for our organization moving forward. Today we attempted to upgrade Nx to 15.8.7. Our next.config.js file has the following:
Yet, ESLint rules are now running on our build. In other words, values in our next.config.js are either being overridden or ignored. I am unclear how something this critical couldn't be caught in peer review. It seems that Next.js support was stable for quite some time, but is now an afterthought. |
We're releasing a patch for this, which should land today. Sorry for the inconvenience. There are additional e2e tests to cover these cases as well. |
Fixed in |
The original issue persists on my end still in |
@hoffination Can you share your next config, or maybe a repo to reproduce the error? |
Here is the new repo using latest Nx. https://github.com/jaysoo/issue-15794 If anyone still has issues please let me know. A reproduction repo would be helpful. |
I still have issue when trying to migrate from
|
I have had this issue ever since upgrading from 15.8.5 to any later version including 15.8.6. nx build can no longer recognize typescript in ts or tsx files: downgrading to 15.8.5 always fixes it. Here is how I run the migrate from 15.8.5 to 15.8.9:
Here's a portion of the build errors showing how it can't parse a typescript file:
The nx report after upgrading to 15.8.9:
Running |
I'll try a few things locally to see if I can reproduce it. |
I could not reproduce with a fresh Nx 14.8.8 repo that I migrated to 15.8.9. I'm guessing the issue is This fresh config works: //@ts-check
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { withNx } = require('@nrwl/next/plugins/with-nx');
/**
* @type {import('@nrwl/next/plugins/with-nx').WithNxOptions}
**/
const nextConfig = {
nx: {
// Set this to true if you would like to to use SVGR
// See: https://github.com/gregberge/svgr
svgr: false,
},
};
module.exports = withNx(nextConfig); But if you tried to compose plugins by calling // This won't work since `withNx` returns a function
const configWithNx = withNx({});
module.exports = {
...configWIthNx,
//...
}
// This will work since we are passing the phase down
const configWithNx = withNx({});
module.exports = async (...args) => {
return {
...(await configWithNx(...args))
//...
}
}; Also, do not use If you are running into issues, please share the next config so I can see if there's anything that needs to be updated. Update: Added async-await to the code snippet since it was missing. |
We do something like the following:
Given your explanation this is no longer possible given that it returns a function now. Moving withNx outside withSentryConfig fixes it, but then i think the sourcemaps stuff is probably off (have not verified this yet, but sentry says to put their withSentryConfig as most outside as possible). I'll try with the ... operator and see if that works properly. Btw, is this @jaysoo i tried this but am unsure where to put the plugins reduce function result
|
This isn't needed to use workspace libs, with or without buildable libraries. Something like this should work with Sentry: module.exports = async (phase, context) => {
let updatedConfig = plugins.reduce((acc, fn) => fn(acc), nextConfig);
updatedConfig = await withNx(updatedConfig)(phase, context);
updatedConfig = withSentryConfig(updatedConfig, SentryWebpackPluginOptions);
return updatedConfig;
} We may need to expose a |
@charleskoehl thanks, at least now I was able to migrate from next step will be to align it to the latest, but I run now into your problem as well, |
@Serj10GR Make sure if you are using the return from |
Thanks @jaysoo. I am indeed using //@ts-check
// eslint-disable-next-line @typescript-eslint/no-var-requires
const withPlugins = require('next-compose-plugins')
const { withNx } = require('@nrwl/next/plugins/with-nx')
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
const intercept = require('intercept-stdout')
// safely ignore recoil warning messages in dev (triggered by HMR)
function interceptStdout(text) {
if (text.includes('Duplicate atom key')) return ''
return text
}
if (process.env.NEXT_PUBLIC_VERCEL_ENV === 'development') {
intercept(interceptStdout)
}
const nextConfig = {
productionBrowserSourceMaps: false,
experimental: {
allowMiddlewareResponseBody: true,
},
}
module.exports = async (phase, { defaultConfig }) =>
withPlugins([withNx, withBundleAnalyzer], nextConfig)(phase, {
...defaultConfig,
...nextConfig,
}) I removed the bundle analyzer and rewrote next.config.js below. //@ts-check
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { withNx } = require('@nrwl/next/plugins/with-nx')
const intercept = require('intercept-stdout')
// safely ignore recoil warning messages in dev (triggered by HMR)
function interceptStdout(text) {
if (text.includes('Duplicate atom key')) return ''
return text
}
if (process.env.NEXT_PUBLIC_VERCEL_ENV === 'development') {
intercept(interceptStdout)
}
const nextConfig = {
productionBrowserSourceMaps: false,
}
module.exports = withNx(nextConfig) Now I am able to migrate to 15.8.9 and build all apps. |
Thanks! This snippet almost works, except that the withNx doesn't accept a context argument, just a phase. Works for me with both 13.1.6 and with 13.2.4 locally, thank you! |
still have problems with it :( this is my next.config
|
@Serj10GR You'll need to remove const { withNx } = require('@nrwl/next/plugins/with-nx');
const nextTranslate = require('next-translate');
const { withSentryConfig } = require('@sentry/nextjs');
module.exports = async (phase, context) => {
const isProd = process.env.NODE_ENV === 'production';
const assetPrefix = (isProd && phase !== '') ? phase: undefined;
const buildId = isProd ? `${assetPrefix.substring(1).replaceAll('/', '-')}` : '';
const addNx = withNx({
assetPrefix,
generateBuildId: async () => buildId,
poweredByHeader: false,
publicRuntimeConfig: {
assetPrefix,
},
trailingSlash: true,
sentry: {
hideSourceMaps: true,
},
});
let config = await addNx(phase);
config = await nextTranslate(config);
config = await withSentryConfig(config, SentryWebpackPluginOptions);
return config;
}; |
I will close this issue since the original problem is fixed. |
Thanks for figuring out what was going on @jaysoo ! I'm still having a few issues as I'm not sure how to both configure webpack and run this async:
|
@jaysoo your last config works locally ok, but after the build is done we have an error when trying to start
any idea on this ? |
@SergiuGrisca Hmm. Is that starting with |
Hey @jaysoo I saw a commit about it but could not be sure. Did you expose composePlugins function, can we use it now? If you did, is there any api docs about it? |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Current Behavior
I can no longer build my Nextjs app with nx 15.8.7. I guess it's related to previous issues reported in the Nextjs repo and this PR #15650.
Expected Behavior
I can build the app.
GitHub Repo
No response
Steps to Reproduce
May provide a repro later if I have time.
Nx Report
Failure Logs
Additional Information
No response
The text was updated successfully, but these errors were encountered: