Skip to content

Fix browser export interop by routing bundlers to CJS-typed UMD artifact#4444

Open
Copilot wants to merge 2 commits into
masterfrom
copilot/fix-less-esm-bundler-issue
Open

Fix browser export interop by routing bundlers to CJS-typed UMD artifact#4444
Copilot wants to merge 2 commits into
masterfrom
copilot/fix-less-esm-bundler-issue

Conversation

Copilot AI commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Since less is "type": "module", bundlers resolving the "browser" export to dist/less.js can interpret the UMD file as ESM and lose default-import interop. This updates the browser export target to a CJS-typed path while preserving existing UMD artifacts.

  • Export map alignment for browser bundlers

    • exports["."].browser now points to ./dist/less.cjs instead of ./dist/less.js.
    • Added explicit subpath export for ./dist/less.cjs.
  • Build output update (no format rewrite)

    • Rollup browser build now emits an additional dist/less.cjs file with the same UMD output shape as dist/less.js.
    • dist/less.js and dist/less.min.js remain unchanged as published artifacts.
  • Contract test update

    • Updated export-pattern checks to assert the browser entry is ./dist/less.cjs and that the file exists.
{
  "exports": {
    ".": {
      "browser": "./dist/less.cjs",
      "import": "./lib/less-node/index.js",
      "require": "./dist/less-node.cjs"
    }
  }
}

Copilot AI changed the title [WIP] Fix less.js packaging issue for bundlers Fix browser export interop by routing bundlers to CJS-typed UMD artifact Jun 10, 2026
Copilot AI requested a review from matthew-dean June 10, 2026 21:53
@matthew-dean matthew-dean marked this pull request as ready for review June 11, 2026 17:24
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 11, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dist/less.js (browser build) is UMD but since 4.6.0 treated as ESM due to "type": "module" – breaks bundlers

2 participants