SolidZORO / next-plugin-antd-less

🎩 Use Antd (Less) with Next.js v12, Zero Dependency on other Next-Plugins.
MIT License
345 stars 48 forks source link

require.extensions is not defined #44

Closed happyhunter7 closed 3 years ago

happyhunter7 commented 3 years ago

Hi, @SolidZORO require.extensions is deprecated and no longer maintained...and it throws errors ....Cannot set property '.less' on undefined. These errors are thrown only if you use a pre-bundled next config with webpack....

And I have a simple solution. Can we add a check like that below...........So if the user has require.extensions it will use that and everything will work as usual......but if he doesn't have it because have another node version or have a bundled config it will not throw errors but also will work ok.

// fix: prevents error when .less files are required by node
if (require && require.extensions) {
  require.extensions['.less'] = () => {};
}
happyhunter7 commented 3 years ago

@SolidZORO I've opened 2 PR for that https://github.com/SolidZORO/next-plugin-antd-less/pull/45 and https://github.com/SolidZORO/next-plugin-antd-less/pull/46 Can you pls take a look and if everything is ok to let's publish it because I think a lot of users have at the moment this problem.

SolidZORO commented 3 years ago

Good Job, I'll release the new version as soon as I've solved another issue.

SolidZORO commented 3 years ago

Hi, @Gherciu, If you have time, please help me, and use 1.1.0, I updated the less-loader to 8.0, it was not possible to upgrade when it was discussed on https://github.com/SolidZORO/next-plugin-antd-less/issues/30, but I tried it today and found that I could It works fine now.

SolidZORO commented 3 years ago

@Gherciu sorry, No need to try. I found out that my local less-loader deps cache was still 7, so it worked, but not when I couldn't send the vercel package. ...... Then I downgraded the version back to 7.

When I went to the less-loader website, I saw that https://github.com/webpack-contrib/less-loader/blob/master/CHANGELOG.md#-breaking-changes already explicitly says that 8.0 webpack The minimum version is 5.