feat: migrate to native ESM with no build step#4411
Merged
matthew-dean merged 11 commits intoless:masterfrom Mar 9, 2026
Merged
feat: migrate to native ESM with no build step#4411matthew-dean merged 11 commits intoless:masterfrom
matthew-dean merged 11 commits intoless:masterfrom
Conversation
- 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
|
Important Review skippedToo many files! This PR contains 157 files, which is 7 over the limit of 150. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (7)
📒 Files selected for processing (157)
You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
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/.
npx doesn't reliably find binaries with pnpm. Since playwright is already a devDependency, use pnpm exec to run the installed version.
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.
Makes pnpm exec playwright work from workspace root in CI.
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.
…ed 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/tolib/— source files are shipped directly with no compilation step"type": "module"topackage.json, targeting Node 18+src/→lib/transpilation step is removed entirelylib/directly. Bundle size actually decreased (509KB → 500KB unminified, 158KB → 153KB minified).cjs:Gruntfile.cjs,.eslintrc.cjs,@plugintest fixtures, and browser generator configsfail-fast: false, playwright moved to root devDependencies,pnpm execfor playwright installKey changes
.jsextensions added to all relative imports for ESM resolutioncreateRequire()used for npm package resolution and JSON imports (optional deps likeclean-css,source-map)bin/lessc, test files, and build scripts converted from CJS to ESMfail-fast: falseso all jobs run independentlyTest plan
npm test)node build/rollup.js --dist)bin/lessccompiles.lessfiles)