Skip to content

v5 compiler fixes around cjs bundles and error messaging - #7027

Merged
johnjenkins merged 4 commits into
v5from
fix/v5-cjs-bundling
Nov 20, 2026
Merged

johnjenkins merged 4 commits into
v5from
fix/v5-cjs-bundling

Conversation

@johnjenkins

@johnjenkins johnjenkins commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What is the current behavior?

Found while testing Ionic against v5 (ionic-framework#31403 comment):

  • With loader-bundle cjs: true in a "type": "module" package, require() of the package or its loader fails:
    • Chunks and lazy entries in cjs/ still end in .js, so Node loads them as ESM.
    • cjs/loader.cjs throws Invalid URL. Because the build uses platform: 'browser', Rolldown renders import.meta.url as {}.url in CJS.
  • Invalid selectors (e.g. .a::before:dir(rtl)) fail the build with only Lightning CSS's Invalid state. The selector isn't named, and for Sass the line number points at compiled CSS.

Additionally, from feedback:

  • The package.json "files" error ("Unable to find X within the package.json files array") reads as though X is missing from files, when it's actually missing on disk.

GitHub Issue Number: N/A

What is the new behavior?

  • cjs/ gets a {"type":"commonjs"} package.json.
  • A CJS-only output plugin replaces {}.url with require("url").pathToFileURL(__filename).href. This is the expression Rolldown itself emits for platform: 'node'.
  • Lightning CSS selector errors now name the offending selector. For a pseudo-class after a pseudo-element, the message also says how to fix it.
  • The "files" error now reads: "X" is listed in the package.json "files" array but could not be found on disk.

Documentation

  • BREAKING_CHANGES.md: new "CSS Autoprefixing and Minification Use Lightning CSS" section, covering stricter selector parsing.

Does this introduce a breaking change?

  • Yes
  • No

Testing

New spec and e2e tests

@johnjenkins
johnjenkins requested a review from a team as a code owner November 19, 2026 23:10
@johnjenkins
johnjenkins merged commit 0884102 into v5 Nov 20, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant