Skip to content

fix(webpack): cap less version to <4.6.0 to avoid ESM incompatibility#34781

Merged
FrozenPandaz merged 6 commits intomasterfrom
fix/cap-less-version-esm
Mar 11, 2026
Merged

fix(webpack): cap less version to <4.6.0 to avoid ESM incompatibility#34781
FrozenPandaz merged 6 commits intomasterfrom
fix/cap-less-version-esm

Conversation

@FrozenPandaz
Copy link
Collaborator

Current Behavior

@nx/webpack specifies "less": "^4.1.3" as a dependency, which allows less@4.6.0 to be installed. However, less@4.6.0 switched to ESM ("type": "module"), and less-loader@11.x uses require() to load it. This causes a runtime error:

class WebpackFileManager extends implementation.FileManager {
                                                ^
TypeError: Class extends value undefined is not a constructor or null

This breaks any React/webpack project that uses Less stylesheets (e.g. the "should support global and css modules" e2e test).

Expected Behavior

The less version range is capped to >=4.1.3 <4.6.0, preventing the incompatible ESM-only version from being installed. Less stylesheets compile correctly with webpack and less-loader.

Related Issue(s)

N/A - discovered via e2e test failure

less@4.6.0 switched to ESM ("type": "module"), which breaks
less-loader@11.x that uses require() to load it, causing
"Class extends value undefined is not a constructor or null" errors.
@FrozenPandaz FrozenPandaz requested a review from a team as a code owner March 10, 2026 21:34
@netlify
Copy link

netlify bot commented Mar 10, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 7f4af00
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69b094412fb006000832e965
😎 Deploy Preview https://deploy-preview-34781--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Mar 10, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 7f4af00
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69b09441296bbf00083f8f81
😎 Deploy Preview https://deploy-preview-34781--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud
Copy link
Contributor

nx-cloud bot commented Mar 10, 2026

View your CI Pipeline Execution ↗ for commit 7f4af00

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 12m 41s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3m 33s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 8s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-10 23:04:24 UTC

@FrozenPandaz FrozenPandaz force-pushed the fix/cap-less-version-esm branch from ba519d0 to cdd5091 Compare March 10, 2026 21:40
@FrozenPandaz FrozenPandaz requested a review from a team as a code owner March 10, 2026 21:40
…r-rspack

- Add missing `less` dependency (capped <4.6.0) to @nx/rspack and
  @nx/angular-rspack
- Bump less-loader to ^12.2.0 for @nx/rspack (already done for webpack
  and angular-rspack)
- Bump root less-loader pin to 12.2.0
@FrozenPandaz FrozenPandaz requested a review from a team as a code owner March 10, 2026 21:46
…ular-rspack

Both packages use less-loader which requires less at runtime.
Add less (capped <4.6.0 for ESM compat) and configure eslint
dependency-checks to ignore it.
@FrozenPandaz FrozenPandaz requested a review from a team as a code owner March 10, 2026 21:51
less is a peer dep of less-loader, so consumers provide it.
Only @nx/webpack ships it as a convenience direct dep.
@FrozenPandaz FrozenPandaz force-pushed the fix/cap-less-version-esm branch from b1b7363 to 58b3c65 Compare March 10, 2026 21:55
Bump root less pin to latest CJS-compatible version.
Remove less-loader from rspack eslint ignoredDependencies since
dependency-checks detects require.resolve usage.
@FrozenPandaz FrozenPandaz enabled auto-merge (squash) March 10, 2026 22:00
Copy link
Contributor

@nx-cloud nx-cloud bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.

Nx Cloud has identified a possible root cause for your failed CI:

We were unable to attribute this failure to the PR's code changes. The test fails during Playwright browser installation due to a hash sum mismatch when fetching Google Chrome's package list from dl.google.com — a transient external CDN issue unrelated to the less version capping introduced here. Our recommendation is to re-run the pipeline once Google's package repository has re-synced.

No code changes were suggested for this issue.

Trigger a rerun:

Rerun CI

Nx Cloud View detailed reasoning on Nx Cloud ↗

🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.


🎓 Learn more about Self-Healing CI on nx.dev

@FrozenPandaz FrozenPandaz merged commit 9e5ba5a into master Mar 11, 2026
25 of 26 checks passed
@FrozenPandaz FrozenPandaz deleted the fix/cap-less-version-esm branch March 11, 2026 02:10
@github-actions
Copy link
Contributor

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants