Introducing a new way to review your PRs.

Read the announcement

less / less.js

Less. The dynamic stylesheet language.

View on GitHub

17 documents · Updated Sep 7, 2026

overview

Knowledge Base updated: 2026-09-06

Less.js knowledge base

Orientation

Less.js is a JavaScript implementation of the Less stylesheet language. Its shared compiler parses Less source into a tree, evaluates language semantics, applies visitors and transforms, and emits CSS, errors, and optional source maps.

The compiler core lives under packages/less/lib/less/, with parser, tree-node, visitor, function, import, and environment subsystems separated from the Node.js, browser, and lessc integration layers. User-facing language behavior is implemented through the parser and evaluated tree model rather than a standalone language runtime.

Repository-level delivery state is concentrated in the root workspace manifest, package manifests, Rollup build configuration, release scripts and workflows, and the shared test-data fixture packages. Browser bundles and published package artifacts are generated from the shared compiler entry points.

System architecture

flowchart LR
  Source[Less source] --> Parser[Parser]
  Parser --> Tree[Tree nodes]
  Tree --> ImportManager[Import manager]
  ImportManager --> FileManagers[File managers]
  Tree --> Eval[Evaluation contexts]
  Eval --> Functions[Built-in functions]
  Eval --> Plugins[Plugin manager]
  Eval --> Visitors[Visitors and transforms]
  Visitors --> CSS[CSS generation]
  CSS --> Output[CSS, errors, source maps]
  Node[Node API and lessc] --> Parser
  Browser[Browser runtime] --> Parser
  Build[Rollup builds] --> Browser
  Workspace[Workspace manifests] --> Build
  Tests[Fixtures and test runners] --> Node
flowchart LR
  CLI[lessc options] --> NodeEntry[Node entry point]
  NodeEntry --> Render[less.render]
  BrowserEntry[Browser stylesheet discovery] --> Render
  Render --> Parse[Parse and import]
  Parse --> Evaluate[Evaluate tree]
  Evaluate --> Transform[Visitor transforms]
  Transform --> Result[CSS and source map result]

Glossary

  • Tree node — An object in the parsed Less syntax tree; nodes carry semantic behavior and source-location context used throughout compilation.
  • Visitor — A traversal and transformation stage applied to the evaluated tree, including selector extension, join, visibility, and CSS generation work.
  • File manager — An environment-specific resolver and loader selected to satisfy an @import or plugin request.
  • Detached ruleset — A ruleset value that can be stored, passed, invoked, and evaluated in an appropriate scope.
  • Workspace package — A package managed from the root workspace, including the compiler, test data, and import-module test packages.

Codebase-wide invariants

  • Parsing preserves source context on tree structures so later diagnostics and generated output can refer back to input locations; evidence: packages/less/lib/less/parser/ and packages/less/lib/less/tree/**.
  • Environment integrations use the shared compiler pipeline instead of implementing separate language semantics; evidence: packages/less/lib/less-node/, packages/less/lib/less-browser/, and packages/less/lib/less/.
  • Import resolution is mediated through file-manager selection rather than direct parser filesystem access; evidence: packages/…/import-manager.js and packages/less/lib/less/environment/.
  • Browser-distributable output is built from configured package entry points rather than maintained as independent source; evidence: packages/…/rollup.config.js and packages/…/package.json.
  • Versioned workspace delivery requires coordinated package metadata; evidence: package.json, packages/…/package.json, packages/…/package.json, and packages/…/package.json.

Routing table

Path or triggerDocumentation
packages/…/index.js, packages/…/parse.js, packages/…/render.js, packages/…/transform-tree.jsLess compiler pipeline
packages/less/lib/less/parser/**, packages/less/lib/less/tree/**Parser and syntax tree
packages/…/import-manager.js, packages/less/lib/less/environment/**, packages/…/file-manager.js, packages/…/file-manager.jsImports and file resolution
packages/…/contexts.js, packages/less/lib/less/visitors/**, packages/…/ruleset.js, packages/…/ruleset-call.jsEvaluation and CSS generation
packages/less/lib/less/functions/**, packages/…/color.js, packages/…/dimension.js, packages/…/expression.jsBuilt-in functions and values
packages/…/plugin-manager.js, packages/…/plugin-loader.js, packages/…/plugin-visitor.jsPlugin architecture
packages/less/lib/less-node/**, packages/less/lib/less-browser/**, packages/less/bin/lesscNode, browser, and CLI integrations
packages/less/lib/less-node/**, packages/less/bin/lessc, packages/less/test/**/lessc*Node API and lessc
packages/less/lib/less-browser/**, packages/less/test/browser/**, packages/less/test/browser-specs/**Browser runtime
packages/…/declaration.js, packages/…/mixin-*.js, packages/…/ruleset.js, packages/…/parser.jsLess language features
packages/…/variable.js, packages/…/mixin-*.js, packages/…/detached-ruleset.js, packages/…/namespace-value.jsVariables, mixins, and namespaces
packages/…/selector.js, packages/…/extend.js, packages/…/media.js, packages/…/join-selector-visitor.js, packages/…/extend-visitor.jsSelectors, extends, and at-rules
packages/less/test/**, packages/test-data/**, packages/test-import-module/**Test and fixture system
package.json, packages/…/package.json, packages/…/rollup.config.js, packages/…/package.json, packages/…/package.jsonPackaging and distributable builds
.github/workflows/**, package.json, packages/…/package.json, packages/…/package.json, packages/…/package.jsonRelease automation
packages/less/benchmark/**, packages/less/benchmarks/**, packages/less/test/benchmark/**Performance benchmarks