Skip to content

ESM only with Pigment CSS and Next.JS #913

@danbalarin

Description

@danbalarin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions