Skip to content
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): enhance support for custom server with SWC configuration #29895

Merged
merged 1 commit into from
Feb 6, 2025

Conversation

ndcunningham
Copy link
Contributor

@ndcunningham ndcunningham commented Feb 5, 2025

This pull request contains a few changes to enhance our swc support for Next.js with a custom server.

Issues

Currently, we have a few issues with our configuration when using executors for Next.js with a custom server:

  1. The custom server does not have an independent build configuration.
  2. The custom server does not have an independent output directory.
  3. Serving via @nx/next-server or via @nx/js:node with configurations production and development does not always work. (These are contained inside project.json).

Changes

All the above issues have been addressed

  1. We now have an independent swc build configuration called.server.swrc (follows the same format as .eslintrc, .babelrc) etc...
  2. Now each custom server output will be named {app}-server such that if you have multiple custom servers for multiple apps the names will not clash.
  3. Serving now works out of the box but can be adjusted to suit your needs via updating the custom server entry file main.ts

@ndcunningham ndcunningham added scope: nextjs Issues related to NextJS support for Nx scope: js labels Feb 5, 2025
@ndcunningham ndcunningham self-assigned this Feb 5, 2025
@ndcunningham ndcunningham requested review from a team as code owners February 5, 2025 18:04
@ndcunningham ndcunningham requested a review from Coly010 February 5, 2025 18:04
Copy link

vercel bot commented Feb 5, 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 Feb 6, 2025 4:31pm

Copy link

nx-cloud bot commented Feb 5, 2025

View your CI Pipeline Execution ↗ for commit c4d18f3.

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 19m 22s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 21s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx format:check --base= --he... ✅ Succeeded 12s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 10s View ↗
nx documentation ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2025-02-06 18:22:36 UTC

@ndcunningham ndcunningham force-pushed the fix/nextjs-custom-server-caching branch from 816013e to 1d7b547 Compare February 5, 2025 19:09
@ndcunningham ndcunningham marked this pull request as draft February 5, 2025 19:33
@ndcunningham ndcunningham force-pushed the fix/nextjs-custom-server-caching branch from 1d7b547 to 7df7159 Compare February 5, 2025 19:34
@ndcunningham ndcunningham force-pushed the fix/nextjs-custom-server-caching branch 3 times, most recently from a8d9697 to 5406bad Compare February 5, 2025 21:01
@ndcunningham ndcunningham force-pushed the fix/nextjs-custom-server-caching branch from 5406bad to c45c9e0 Compare February 5, 2025 21:21
@ndcunningham ndcunningham marked this pull request as ready for review February 6, 2025 16:28
@ndcunningham ndcunningham force-pushed the fix/nextjs-custom-server-caching branch from c45c9e0 to c4d18f3 Compare February 6, 2025 16:28
@ndcunningham ndcunningham merged commit 29e5ce2 into master Feb 6, 2025
12 checks passed
@ndcunningham ndcunningham deleted the fix/nextjs-custom-server-caching branch February 6, 2025 18:34
FrozenPandaz pushed a commit that referenced this pull request Feb 8, 2025
…#29895)

This pull request contains a few changes to enhance our swc support for
Next.js with a custom server.

### Issues
Currently, we have a few issues with our configuration when using
executors for Next.js with a custom server:

1. The custom server does not have an independent build configuration.
2. The custom server does not have an independent output directory.
3. Serving via `@nx/next-server` or via `@nx/js:node` with
configurations `production` and `development` does not always work.
(These are contained inside `project.json`).

### Changes
All the above issues have been addressed

1. We now have an independent swc build configuration
called`.server.swrc` (_follows the same format as `.eslintrc`,
`.babelrc`_) etc...
2. Now each custom server output will be named `{app}-server` such that
if you have multiple custom servers for multiple apps the names will not
clash.
3. Serving now works out of the box but can be adjusted to suit your
needs via updating the custom server entry file `main.ts`

(cherry picked from commit 29e5ce2)
isaacplmann pushed a commit that referenced this pull request Feb 11, 2025
…#29895)

This pull request contains a few changes to enhance our swc support for
Next.js with a custom server.

### Issues
Currently, we have a few issues with our configuration when using
executors for Next.js with a custom server:

1. The custom server does not have an independent build configuration.
2. The custom server does not have an independent output directory.
3. Serving via `@nx/next-server` or via `@nx/js:node` with
configurations `production` and `development` does not always work.
(These are contained inside `project.json`).

### Changes
All the above issues have been addressed

1. We now have an independent swc build configuration
called`.server.swrc` (_follows the same format as `.eslintrc`,
`.babelrc`_) etc...
2. Now each custom server output will be named `{app}-server` such that
if you have multiple custom servers for multiple apps the names will not
clash.
3. Serving now works out of the box but can be adjusted to suit your
needs via updating the custom server entry file `main.ts`
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
scope: js scope: nextjs Issues related to NextJS support for Nx
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants