elado / next-with-less

Next.js + Less CSS Support
MIT License
143 stars 24 forks source link

Cannot set property regexLikeCss of #<Object> which has only a getter #34

Closed hqwlkj closed 1 year ago

hqwlkj commented 1 year ago

image

yarn list v1.22.19
warning Filtering by arguments is deprecated. Please use the pattern option instead.
└─ next@13.3.1
✨  Done in 0.72s.
bingoYB commented 1 year ago

same problem

viztor commented 1 year ago

32

johnmagbag1995 commented 1 year ago

Same issue

"next": "13.4.0", "antd": "^4.24.8", "next-compose-plugins": "^2.2.1",

AntiMoron commented 1 year ago

Same issue.

elado commented 1 year ago

Hi all. I was able to repro this but unfortunately couldn't find a proper solution yet.

The monkeypatch is supposed to allow support for image URLs inside less files. E.g. background-image: url('./image.png'). Looks like Node is blocking writing into that module. something changed about Next.js transpilation in the recent version. I tried using Object.defineProperty, Reflect.set, Reflect.defineProperty but they either don't work (the property isn't applied) or the error mentioned is thrown.

This PR is not fixing it - obj = { ...obj, prop: 'val' } doesn't mutate the object, but the intention is to mutate.

At this point, I see the following options:

  1. Give up on url support in less files (least favorite option)
  2. Find a JS solution that allows rewriting the export - I'm open to ideas
  3. Use a different patching mechanism, like overwriting Module.prototype.require (definitely not a fan of this but it might be the only option)
AntiMoron commented 1 year ago

I've created a discussion in nextjs to have this supported. Upvote this if you support my proposal.

https://github.com/vercel/next.js/discussions/49665

Mnigos commented 1 year ago

same issue here

elado commented 1 year ago

Released a fix in v3.0.0

gabek commented 1 year ago

Thank you!