Code Monkey home page Code Monkey logo

Comments (6)

linkscope avatar linkscope commented on May 27, 2024 2

I have the same issue, downgrade unocss and @unocss/postcss to 0.58.9 is works.

from unocss.

kwaa avatar kwaa commented on May 27, 2024 1

It looks like Next.js is still trying to require instead of import despite the PostCSS ESM Config, and there's nothing I can do about it.

An error occurred in `next/font`.

TypeError: require(...) is not a function
    at /workspaces/sandbox/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/build/webpack/config/blocks/css/plugins.js:62:63
    at plugin (/workspaces/sandbox/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/build/webpack/config/blocks/css/plugins.js:30:44)
    at Processor.normalize (/workspaces/sandbox/node_modules/.pnpm/[email protected]/node_modules/postcss/lib/processor.js:18:13)
    at new Processor (/workspaces/sandbox/node_modules/.pnpm/[email protected]/node_modules/postcss/lib/processor.js:11:25)
    at postcss (/workspaces/sandbox/node_modules/.pnpm/[email protected]/node_modules/postcss/lib/postcss.js:26:10)
    at /workspaces/sandbox/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/build/webpack/config/blocks/css/index.js:127:37
    at async /workspaces/sandbox/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/build/webpack/loaders/next-font-loader/index.js:86:33
    at async Span.traceAsyncFn (/workspaces/sandbox/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/trace/trace.js:154:20)

from unocss.

sibbng avatar sibbng commented on May 27, 2024

#3380 changed the behavior of how CJS module is resolved. I took a quick look at it but I don't know how we could fix/restore the previous behavior.

Similar issue: #3724. They solved the issue by moving the config file to ESM format but I don't think this is possible for Next.js. If I remember correctly Next.js was very strict about PostCSS config format.

/cc @kwaa @userquin

from unocss.

kwaa avatar kwaa commented on May 27, 2024

I don't think this is possible for Next.js. If I remember correctly Next.js was very strict about PostCSS config format.

It looks like next.js@^14.2.0-canary.25 already supports PostCSS ESM Config.

vercel/next.js#34448 (comment)
vercel/next.js#63109

It seems like plugins still need to be provided as strings though. I'll look into that later.

from unocss.

userquin avatar userquin commented on May 27, 2024

The problem is the default export in cjs, we need to use export = <default_export> in d.ts and d.cts files. I send a PR to fix all dual esm/cjs packages, check #3750

from unocss.

turkgenciyim avatar turkgenciyim commented on May 27, 2024

I have the same issue, downgrade unocss and @unocss/postcss to 0.58.9 is works.

This worked for me, thanks a lot!

from unocss.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.