Skip to content

feat(lessc): wire compress, source maps, URL rewriting, and math CLI flags - #4543

Merged
matthew-dean merged 2 commits into
less:alphafrom
matthew-dean:feat/lessc-newer-flags
Sep 18, 2026
Merged

matthew-dean merged 2 commits into
less:alphafrom
matthew-dean:feat/lessc-newer-flags

Conversation

@matthew-dean

Copy link
Copy Markdown
Member

The less.render() API already supports compress, source maps (including the
rootpath/basepath/url path variants and inline data URIs), URL rewriting,
and math modes — but lessc rejected all of those flags and pointed users at
the API. This forwards them from the CLI so files can be compiled with the same
surface as the programmatic API.

New / changed flags

  • --compress / -x
  • --math=<always|parens-division|parens>
  • --rewrite-urls[=all|local|off], --rootpath=<path>, --url-args=<args>
  • --source-map[=file] — writes the sidecar .map next to the output and
    annotates the CSS with its basename; --source-map-inline embeds a base64
    data URI instead of writing a file
  • --source-map-include-source, --source-map-rootpath, --source-map-basepath,
    --source-map-url for the path variants
  • --collapse-nesting now also accepts =native|compact

The source-map engine already honors rootpath/basepath/url and sets the map's
file field, so no engine change was needed — this exposes and tests them
through the CLI. When source maps are requested but CSS goes to stdout (no output
file for a sidecar), the map is inlined.

Tests / docs

  • test/lessc-alpha.mjs gains positive coverage for every new flag: compress,
    math, url-args, rootpath, --source-map (sidecar .map shape + file field +
    sources), --source-map-inline (data URI, no sidecar), and the
    basepath/rootpath/include-source/url path variants.
  • The help text and V5-STATUS.md are updated: the CLI-flags row and the
    source-map path-variant note both move from "in progress" to supported.

Full test:alpha (typecheck, build, lessc, support, source-maps, fixtures),
publish-dry-run, and the packed-consumer proof pass locally.

The render API already supports these options; the CLI rejected them. Forward
them from lessc so files can be compiled with the same surface as less.render():

- --compress / -x
- --math=<mode>
- --rewrite-urls[=all|local|off], --rootpath=<path>, --url-args=<args>
- --source-map[=file] with the sidecar .map written next to the output and the
  CSS annotated with its basename; --source-map-inline embeds a data URI instead
- --source-map-include-source, --source-map-rootpath, --source-map-basepath,
  --source-map-url for the path variants
- --collapse-nesting now also accepts =native|compact

Source maps already honor rootpath/basepath/url and the map's file field, so no
engine change was needed — this exposes them through the CLI and covers them.
Help text and the feature-status page are updated to match; the alpha CLI tests
add positive coverage for every new flag plus the .map sidecar.
@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 8c069a30-0faa-4e60-b025-93c318fb7cda

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@greptile-apps

greptile-apps Bot commented Sep 18, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

The PR should not merge until explicit source-map files outside the CSS directory produce an annotation that resolves to the sidecar actually written.

Summary

This PR exposes existing render functionality through the alpha lessc CLI.

  • Adds compression, math, URL-rewriting, source-map, and expanded nesting flags.
  • Writes source-map sidecars or embeds inline maps as appropriate.
  • Updates CLI help, status documentation, and end-to-end CLI coverage.
  • Explicit source-map paths in directories other than the CSS directory currently produce an annotation pointing to the wrong location.

Reviews (1) · Last reviewed commit: "feat(lessc): wire compress, source maps,..."

Comment thread packages/less/bin/lessc Outdated
When --source-map=FILE writes the map to a different directory than the CSS
output, the sourceMappingURL must point at it relative to the output directory
(dist/app.css -> ../maps/app.map). It previously used the bare basename, which
made clients request a nonexistent map next to the CSS. The same-directory
common case is unchanged.
@matthew-dean
matthew-dean merged commit c20ed01 into less:alpha Sep 18, 2026
10 checks passed
@matthew-dean
matthew-dean deleted the feat/lessc-newer-flags branch September 18, 2026 21:01
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