elado / next-with-less

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

Update injection of less regexp #32

Closed nike1v closed 1 year ago

nike1v commented 1 year ago

Update injection of less regexp tp work in Next@13.3+ Since they changed the way it works, you need to extend the object insted just replacing the value,

elado commented 1 year ago

I added an example for Next 13.3.1 https://github.com/elado/next-with-less/tree/main/examples/next13.3.1 and it works. Can you elaborate on what's broken?

viztor commented 1 year ago

can confirm

It throws error - Failed to load next.config.mjs, see more info here https://nextjs.org/docs/messages/next-config-error TypeError: Cannot set property regexLikeCss of #<Object> which has only a getter in the 13.3.1 release

nike1v commented 1 year ago

I added an example for Next 13.3.1 https://github.com/elado/next-with-less/tree/main/examples/next13.3.1 and it works. Can you elaborate on what's broken?

HI! I just tried your examples, and it does work in this case. But if you try to use your package as an installed one from npm, but nut from ../../src, it will fail with the error I provieded. Please check it.

AntiMoron commented 1 year ago

image @elado Please take a look at this.

AntiMoron commented 1 year ago

I've made some experiments here. Found it hard to set the value. In next 13 it export that value here

And after Webpack compiles this module, that value is exported as a Get-Only property. Which is impossible to redefine. Quite frustrating. I guess better make NextJS enable its customization by creating PRs.

AntiMoron commented 1 year ago

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

elado commented 1 year ago

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

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

Closing this PR and we can continue the discussion here: https://github.com/elado/next-with-less/issues/34