Comments (6)
I have the same issue, downgrade unocss
and @unocss/postcss
to 0.58.9
is works.
from unocss.
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.
#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.
from unocss.
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.
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.
I have the same issue, downgrade
unocss
and@unocss/postcss
to0.58.9
is works.
This worked for me, thanks a lot!
from unocss.
Related Issues (20)
- React如果children中直接跟随文本的情况下会出现 Warning: Received `true` for a non-boolean attribute HOT 4
- @unocss/runtime does not work HOT 2
- 在create-react-app的webpack项目中使用presetTypography预设会报错 HOT 3
- Preset icons empty `prefix` makes things very slow in Nuxt HOT 4
- Selection modifier inheritance differs from TailwindCSS HOT 1
- Use !xxx to display errors HOT 1
- presetAttributify and transformerAttributifyJsx don't work in react18 HOT 1
- perf(todo): Merge hot updates of uno.css to reduce the number of updates HOT 2
- "unocss/vite" resolved to an ESM file. ESM file cannot be loaded by `require` HOT 8
- Error prompt for Unocss plugin in VSCode HOT 3
- install unocss error HOT 1
- vite引入unocss报错 HOT 2
- vscode multi-workspace plugin is invalid HOT 1
- `transformer-directives` transforms opacities incorrectly
- `--at-apply` Hex colors not working HOT 3
- npm ERR! notarget No matching version found for @unocss/[email protected].
- extractors not working with cli
- Directives should ignore inline comments
- `--at-apply` (transformer directive) multiple bug on `0.60.1` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unocss.