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

withNx changes broke compatibility with other NextJS plugins #16278

Closed
raphzandrade opened this issue Apr 12, 2023 · 4 comments · Fixed by #16296
Closed

withNx changes broke compatibility with other NextJS plugins #16278

raphzandrade opened this issue Apr 12, 2023 · 4 comments · Fixed by #16296
Assignees
Labels
outdated scope: nextjs Issues related to NextJS support for Nx type: bug

Comments

@raphzandrade
Copy link

raphzandrade commented Apr 12, 2023

Current Behavior

Apps that use other Next.js plugins, such as remove-imports [ref], may not function properly with the latest version of Nx.

Example

Here's an example of a library component import failure that occurred when using a previously functioning plugin:

image

The next.config.ts file of the application:

image

Removing the plugin resolves the error.

Expected Behavior

It should continue to function with the plugins that were previously operational.

GitHub Repo

https://github.com/raphzandrade/next-errors

Steps to Reproduce

  1. Add any plugin to a NextJS application;
  2. Make sure it uses any component imported from a library;
  3. Serve the application.

Nx Report

Node : 18.13.0
   OS   : darwin x64
   pnpm : 7.26.2
   
   nx                      : 15.9.2
   @nrwl/js                : 15.9.2
   @nrwl/jest              : 15.9.2
   @nrwl/linter            : 15.9.2
   @nrwl/workspace         : 15.9.2
   @nrwl/cypress           : 15.9.2
   @nrwl/eslint-plugin-nx  : 15.9.2
   @nrwl/next              : 15.9.2
   @nrwl/react             : 15.9.2
   @nrwl/nx-cloud          : 15.3.5
   typescript              : 4.9.5

Failure Logs

No response

Additional Information

No response

@AgentEnder AgentEnder added the scope: nextjs Issues related to NextJS support for Nx label Apr 12, 2023
@lourd
Copy link
Contributor

lourd commented Apr 13, 2023

Related issue at #16141 with a fix linked.

@jaysoo jaysoo self-assigned this Apr 13, 2023
@jaysoo
Copy link
Member

jaysoo commented Apr 13, 2023

I think we need to add a composePlugins util similar to @nrwl/webpack so these things are easier to do. The example outlined here is how it can be done for now: #15794 (comment).

@jaysoo
Copy link
Member

jaysoo commented Apr 13, 2023

We'll add something to Nx 16 to make this easier to work with:

const plugins = [
  // Add as many plugins here
  withMDX,
  withNx
  // ...
];

// The composed function will know how to handle normal plugins and plugins that return an async function (e.g. `withNx`).
module.exports = composePlugins(...plugins)({
  // normal next.js config
});

@github-actions
Copy link

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.

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

Successfully merging a pull request may close this issue.

4 participants