fix: revert ESM dynamic import, require less >= 4.6.3#588
Conversation
|
|
|
Please accept CLA |
| "peerDependencies": { | ||
| "@rspack/core": "0.x || ^1.0.0 || ^2.0.0-0", | ||
| "less": "^3.5.0 || ^4.0.0", | ||
| "less": "^3.5.0 || ^4.6.3", |
There was a problem hiding this comment.
Remove this change, it is a breaking change
There was a problem hiding this comment.
I understand the concern, but #578 already introduced an undeclared breaking change. It shipped as a patch (12.3.1 -> 12.3.2) but broke any CJS consumer using Jest without --experimental-vm-modules. That's what this PR is fixing.
The peer dep update is necessary because less@4.0.0–4.6.2 don't ship a real CJS bundle. require('less') on those versions returns a Proxy that breaks at runtime. Without the constraint, reverting to require() would silently break users on less@4.6.0–4.6.2.
Would it make sense to release this as a major (13.0.0) to properly declare the breaking change? That would acknowledge that 12.3.2 was a breaking patch and restore CJS compatibility with the correct constraint.
There was a problem hiding this comment.
We will break developers with old version of less, we should not touch this field at all
There was a problem hiding this comment.
They publish this fix as a patch, so we should do the same, because it is a bug on their side
|
Also please accept CLA |
|
Can you wait? I'm trying to accept it. For some reason it was logged with another account and not this one. |
e922fa6 to
af246be
Compare
|
@lemachadoh because your email in commits is not the same as you accept in CLA, change it |
|
This is due you are using AI, by default they generate no-reply email, not your |
|
hey @alexander-akait everything seems to be fine with the CLA |
less@4.6.3 ships a pre-built CJS bundle (dist/less-node.cjs) and maps the "require" exports condition to it, resolving the ESM/CJS interop issue that prompted the dynamic import workaround in webpack#578. Revert getLessImplementation back to synchronous require() and restore the standard test:only script. Remove peer dependency constraint added in previous commit as it would break users on less@4.0.0-4.6.2. Source map improvements introduced in webpack#578 (sourceMapBasepath, disableSourcemapAnnotation, normalizeSourceMap) are preserved.
54fd554 to
65be0b9
Compare
Problem
PR #578 replaced
require('less')withawait import('less').defaultto work around an ESM/CJS interop issue introduced inless@4.6.x. This was a breaking change shipped as a patch: any CJS consumer that calls the loader in a Jest environment without--experimental-vm-modulesbreaks with:Tracked in: #584
Root Cause Fix in less@4.6.3
less@4.6.3resolves the root cause by shipping a pre-built CJS bundle atdist/less-node.cjsand pointing the"require"exports condition to it:No more Proxy, no more ESM-in-CJS problem.
less-loadercan now safely userequire()again.Changes
getLessImplementationfromasync+await import()back to syncrequire()test:onlyscript tocross-env NODE_ENV=test jest(remove--experimental-vm-modules)exclude: ["transform-dynamic-import"]from babel config (no longer needed)less: "^3.5.0 || ^4.0.0"→"^3.5.0 || ^4.6.3"(4.x users must be on >= 4.6.3)less→^4.6.3sourceMapBasepath: "",disableSourcemapAnnotation: true,normalizeSourceMap) — these are correct and independent of the ESM issueless@4.6.3source map path behaviorTesting
All 110 tests pass.
Use of AI
yes