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

ESM only with Pigment CSS and Next.JS #913

Closed
danbalarin opened this issue Feb 13, 2025 · 1 comment
Closed

ESM only with Pigment CSS and Next.JS #913

danbalarin opened this issue Feb 13, 2025 · 1 comment
Labels
wontfix This will not be worked on

Comments

@danbalarin
Copy link

danbalarin commented Feb 13, 2025

Context

What's your version of nuqs?

2.3.2

What framework are you using?

  • ✅ Next.js (app router)
  • ✅ MUI with Pigment CSS

Which version of your framework are you using?

Not relevant, problem is within Pigment CSS/wyw-in-js

Description

During static analysis the Pigment CSS goes through all the files that are at some point imported within the app. It can be overcome by setting asyncResolve property in pigment config in next.config.js like this:

        asyncResolve: (what) => {
		if (what.includes("nuqs")) {
			return import.meta.resolve(what).replace("file://", "");
		}
		return null;
	},

Although it's not nuqs issue per se, it can be easily fixed until Pigment CSS team implements ESM imports. I don't really know how to report this to Pigment CSS, so if someone could create issue there, it would be awesome.

Reproduction

https://stackblitz.com/edit/github-qz9evuvr?file=src%2Fapp%2Fpage.tsx

Throws with:

 ⨯ unhandledRejection:  Error: This package is ESM only.
  See https://err.47ng.com/NUQS-101 for more details. in/home/projects/bnmiozlkmw.github/node_modules/nuqs/esm-only.cjs
@danbalarin danbalarin added the bug Something isn't working label Feb 13, 2025
@franky47
Copy link
Member

franky47 commented Feb 13, 2025

Thanks for the report (and even better, the solution!).

What version of Node.js are you on? There has been significant effort recently to unflag require(esm) in Node.js 20+, which hopefully will make ESM/CJS interop a thing of the past.

I'll close this as there isn't much to do on our end.

@franky47 franky47 added wontfix This will not be worked on and removed bug Something isn't working labels Feb 13, 2025
@franky47 franky47 closed this as not planned Won't fix, can't repro, duplicate, stale Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants