Skip to content

fix: webpack browser build - use UMD dist/less.js, add CJS bundle#4424

Merged
matthew-dean merged 5 commits intoless:masterfrom
matthew-dean:fix/4423-webpack-browser-umd
Mar 11, 2026
Merged

fix: webpack browser build - use UMD dist/less.js, add CJS bundle#4424
matthew-dean merged 5 commits intoless:masterfrom
matthew-dean:fix/4423-webpack-browser-umd

Conversation

@matthew-dean
Copy link
Copy Markdown
Member

@matthew-dean matthew-dean commented Mar 11, 2026

  • Fixes LESS 4.6.2 causing build error #4423
  • Adds CJS build for complete backwards compatibility with ESM
  • Adds tests for specific loading (such as webpack) scenarios with CJS
  • Removes "proxy" solution for Node v18 loading

Summary by CodeRabbit

  • Chores

    • Version bumped to 4.6.3 across packages.
    • CI test step renamed to "Run node tests (ESM + CJS)" and test scripts updated.
    • Added a beta publish workflow and a convenience publish:beta script.
    • Packaging updated to expose built CommonJS and browser bundles as primary entry points.
  • Tests

    • Expanded Node and browser test suite to validate export/import patterns and bundling.

…ss#4423)

- Browser exports point to dist/less.js (UMD) instead of less-node
- Add CJS bundle (dist/less-node.cjs) for Node require() with module shim
- Remove dead index.js; index.cjs re-exports CJS bundle
- Add export tests: import-patterns, webpack-browser, test-cjs-suite
- CI and publish workflows run test:node (build + CJS + ESM tests)
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Mar 11, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 11, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1a196db3-445e-4dc8-8944-6af44aa430b0

📥 Commits

Reviewing files that changed from the base of the PR and between c242bdd and 15eb439.

📒 Files selected for processing (5)
  • package.json
  • packages/less/build/rollup.js
  • packages/less/package.json
  • packages/test-data/package.json
  • packages/test-import-module/package.json

📝 Walkthrough

Walkthrough

Replaces dynamic CJS entry with a pre-built CommonJS bundle, adds Node-focused test scripts and CI step changes, extends Rollup to produce a CJS node bundle, adds beta publish automation, updates package exports/versions, and introduces tests validating exports and browser bundling.

Changes

Cohort / File(s) Summary
CI/CD Workflow Updates
.github/workflows/ci.yml, .github/workflows/publish.yml
Replaced CI test steps/labels to run pnpm run test:node (step renamed to "Run node tests (ESM + CJS)").
Root package.json
package.json
Bumped root version to 4.6.3; added publish:beta and test:node scripts.
Less package entry & exports
packages/less/index.cjs, packages/less/index.js, packages/less/package.json
Replaced Proxy-based dynamic CJS entry with direct require('./dist/less-node.cjs'); removed index.js entry export; updated main/exports to reference dist/less-node.cjs and added browser targets; bumped package version and test scripts.
Rollup build changes
packages/less/build/rollup.js
Added module-shim (createRequire shim) and inline-package-version transform; introduced a Rollup step to produce a Node-targeted CJS bundle (dist/less-node.cjs) alongside browser bundles.
Gruntfile formatting
packages/less/Gruntfile.cjs
Stylistic quote normalization and minor formatting changes only (no behavior change).
Tests: export & bundling validation
packages/less/test/...
packages/less/test/exports/import-patterns.cjs, packages/less/test/exports/webpack-browser.cjs, packages/less/test/exports/webpack-browser-entry.js, packages/less/test/test-cjs-suite.cjs, packages/less/test/test-cjs.cjs, packages/less/test/test-es6.js
Added CommonJS/webpack/browser-target tests and a CJS test suite; adjusted startup log messages.
Publish automation
scripts/publish-beta.js
New script to compute next beta version, optionally update package.json files, build, optionally test, and publish packages with a beta tag (supports --dry-run and --no-test).
Auxiliary package version bumps
packages/test-data/package.json, packages/test-import-module/package.json
Bumped package versions to 4.6.3 to align with root.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested labels

size:XXL

Poem

🐇 A hop, a build, a bundled song,
CJS snug where proxies were long.
Beta tags shimmer, tests take flight,
Bundles now ready for day or night.
Hop—Less leaps, all systems bright.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly addresses the main changes: adding a CommonJS bundle and using UMD dist/less.js for webpack browser builds, which are the core objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

The inlinePackageVersion plugin used forward-slash path check that
failed on Windows where rollup passes backslash-separated IDs,
leaving the require('../../package.json') unresolved at runtime.
@matthew-dean matthew-dean merged commit 6cafcc0 into less:master Mar 11, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LESS 4.6.2 causing build error

1 participant