-
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
fix(nextjs): remove the need to install @nx/next for production builds #16469
fix(nextjs): remove the need to install @nx/next for production builds #16469
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
@@ -6,4 +6,4 @@ export { componentGenerator } from './src/generators/component/component'; | |||
export { libraryGenerator } from './src/generators/library/library'; | |||
export { pageGenerator } from './src/generators/page/page'; | |||
export { withNx } from './plugins/with-nx'; | |||
export { composePlugins } from './src/utils/config'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved composePlugins
to its own file so we can copy the compiled version to dist during build.
: joinPathFragments(outputDir, '.next'); | ||
} else { | ||
return '.next'; | ||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic will only be needed when running through Nx. i.e. nx serve <app> --prod
24af604
to
d6f3ffa
Compare
packages/next/plugins/with-nx.ts
Outdated
} | ||
|
||
return '.next'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For deployment platforms like Vercel, or a self-contained Docker image, the folder should just be .next
(or whatever the user sets it to).
} | ||
|
||
return nextConfig.distDir || '.next'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Vercel and other platforms (including self-contained Docker images), use .next
or whatever the user sets in their next.config.js
.
}; | ||
} else { | ||
const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inline all of the require
to run only during build phase. We don't need these to production.
ff2eea9
to
23ba8bd
Compare
); | ||
writeFileSync(join(helpersPath, 'with-nx.js'), getWithNxContent()); | ||
writeFileSync( | ||
join(helpersPath, 'compiled.js'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A smaller version of with-nx.js
that does not depend on Nx packages.
19cb3bd
to
3a6f537
Compare
3a6f537
to
56b384f
Compare
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
This PR brings back the compiled version of the
withNx
function. This allows@nx/next
to not be installed as a production dependency, which avoids pulling in@nx/devkit
and other dev packages.Current Behavior
@nx/next
or@nrwl/next
must be installed as production dependency.Expected Behavior
@nx/next
or@nrwl/next
don't need to be installed for the compiled app to run.Related Issue(s)
Fixes #15931