Files
less.js/packages/less/scripts/postinstall.js
Matthew Dean c21e465d58 feat: migrate to native ESM with no build step (#4411)
* feat: migrate to native ESM with no build step

- Rename src/ to lib/ — source files are shipped directly, no compilation
- Add "type": "module" to package.json for native ESM support (Node 18+)
- Convert bin/lessc, test files, and build scripts from CJS to ESM
- Rename Gruntfile.js and .eslintrc.js to .cjs (must remain CommonJS)
- Add .js extensions to all relative import paths for ESM resolution
- Use createRequire() for optional dependency resolution (npm packages, JSON)
- Configure TypeScript for check-only mode (noEmit: true, allowJs: true)
- Update Rollup config to read from lib/ directly
- Update CI matrix to drop Node 16 (minimum Node 18+)
- Browser build is smaller: 500KB (was 509KB), minified 153KB (was 158KB)
- All 139 tests pass

* chore: fix trailing semicolons from linter

* chore: gitignore generated .css.map files in lib/

* fix(ci): restore lts/-3 to test matrix

* chore: stop tracking dist/ build artifacts

Generated browser bundles don't need to be in source control — they're
built during publish and included in the npm package via the files field.
Removes duplicate copies from both root dist/ and packages/less/dist/.

* fix(ci): use pnpm exec for playwright install

npx doesn't reliably find binaries with pnpm. Since playwright is
already a devDependency, use pnpm exec to run the installed version.

* fix(ci): use pnpm --filter for playwright, disable fail-fast

pnpm exec at workspace root can't find playwright binary since it's a
devDependency of the less package. Use --filter to run in that context.
Also disable fail-fast so all matrix jobs complete independently.

* fix(ci): move playwright to root devDependencies

Makes pnpm exec playwright work from workspace root in CI.

* fix: upgrade copy-anything to v3 for ESM compat, fix Windows test paths

copy-anything v2 lacks "type": "module", causing named import failures
on Node 18. v3 has proper ESM exports.

Revert testFolder to absolute path (matching original behavior) so debug
test path replacements match Less compiler output on Windows.

* chore: add CodeRabbit config to raise file review limit

* fix: add files field to package.json, remove postinstall from published package

Restricts npm package to only bin/, lib/, dist/, index.js, and README.md.
Previously shipped test files, Gruntfile, eslint config, etc.
Removes postinstall script (Playwright browser install) which only applies
in the monorepo dev environment and fails when installed from npm.

Verified: npm pack --dry-run shows 120 files (was 229), lessc CLI and
API both work from a clean tarball install.
2026-03-09 16:55:44 -07:00

1.3 KiB