Skip to content

chore: modernize tooling and convert to ESM#21

Merged
zkochan merged 1 commit intomainfrom
chore/modernize-esm
May 8, 2026
Merged

chore: modernize tooling and convert to ESM#21
zkochan merged 1 commit intomainfrom
chore/modernize-esm

Conversation

@zkochan
Copy link
Copy Markdown
Member

@zkochan zkochan commented May 8, 2026

Summary

  • Convert package to ESM (type: module, exports map with types/default).
  • Bump Node engine to >=22.13; modern tsconfig (module/moduleResolution: nodenext, target: es2022, verbatimModuleSyntax).
  • Replace tape + ts-node + tslint + package-preview with the built-in node:test runner driven by tsx. Tests now import from ../src/index.ts directly.
  • Replace Travis with GitHub Actions, matrix testing Node 22/24 across Ubuntu/macOS/Windows.
  • Convert CJS-style import x = require(...) to ESM imports; use createRequire(import.meta.url) for the fallback pnpm/bin/pnpm.cjs lookup that previously relied on require.resolve.
  • Bump the bundled pnpm runtime dep from v6 to v11.
  • Drop the hand-written typings/ stubs in favor of @types/command-exists and @types/cross-spawn.
  • pnpmExec is now a named export (was an anonymous default export). Pulling the function name into the source means consumers and the README no longer rely on .default.
  • Mark the test fixture as its own pnpm workspace root (empty pnpm-workspace.yaml) so the install pnpm runs during the test doesn't bubble up into the outer workspace; gitignore the fixture's auto-generated lockfile.
  • Drop test/fixture/shrinkwrap.yaml (pnpm v0/v1 era).

Breaking changes

  • ESM-only consumers required.
  • Named import: import { pnpmExec } from '@pnpm/exec' (was require('@pnpm/exec').default).
  • Node >= 22.13 required.
  • Bundled pnpm fallback is now v11.

Test plan

  • pnpm install clean
  • pnpm run build produces ESM lib/index.js + lib/index.d.ts
  • pnpm test — fixture install runs and findsDep() returns true
  • CI green on Linux/macOS/Windows × Node 22/24

Summary by CodeRabbit

  • Breaking Changes

    • Package now uses ES modules; requires Node.js ≥22.13
    • Default export replaced with named pnpmExec function
  • New Features

    • Added GitHub Actions CI workflow for automated testing across multiple OS and Node versions
  • Chores

    • Updated examples to modern syntax
    • Updated build tooling and dependencies

- Convert package to ESM (type=module, exports map)
- Bump Node engine to >=22.13
- Replace tape/ts-node/tslint/package-preview with node:test + tsx
- Switch tsconfig to NodeNext, target es2022
- Replace Travis CI with GitHub Actions (Node 22, 24 on Ubuntu/macOS/Windows)
- Convert CJS-style imports to ESM; use createRequire for the fallback
  pnpm binary lookup
- Bump bundled pnpm runtime dep from v6 to v11
- Drop typings/ in favor of @types/command-exists and @types/cross-spawn
- Replace anonymous default export with named export pnpmExec
- Mark test fixture as its own pnpm workspace root so installs run in
  isolation; ignore the auto-generated fixture lockfile
- Drop legacy test/fixture/shrinkwrap.yaml (pnpm v0/v1 era)
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 711e8898-8185-4bc0-bd57-68854a28972e

📥 Commits

Reviewing files that changed from the base of the PR and between 21ce3ad and 7a4fb5e.

⛔ Files ignored due to path filters (2)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • test/fixture/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (15)
  • .github/workflows/ci.yml
  • .gitignore
  • .travis.yml
  • README.md
  • example.js
  • package.json
  • pnpm-workspace.yaml
  • src/index.ts
  • test/fixture/pnpm-workspace.yaml
  • test/fixture/shrinkwrap.yaml
  • test/index.test.ts
  • test/index.ts
  • tsconfig.json
  • tslint.json
  • typings/index.d.ts

📝 Walkthrough

Walkthrough

This PR migrates the @pnpm/exec package from CommonJS to ES modules with named exports, updates build infrastructure from Travis CI to GitHub Actions, transitions tests from tape to Node.js native test runner, and modernizes TypeScript configuration and dependencies to target Node.js 22+.

Changes

ESM Migration & Modernization

Layer / File(s) Summary
Package Configuration & Metadata
package.json, pnpm-workspace.yaml
Version bumped to 4.0.0, ESM declared via type: "module", explicit exports map with types added, build/test scripts updated to tsx --test and rimraf lib && tsc, engine requirements set to node >=22.13 and pnpm v11, esbuild allowed in workspace builds.
TypeScript Configuration
tsconfig.json, typings/index.d.ts, tslint.json
Module system switched to nodenext, target raised to es2022, strict mode consolidated, rootDir set to src, ambient type declarations removed (now published as exports), TSLint config removed.
Core Library ESM Conversion
src/index.ts
Default export replaced with named exports pnpmExec function and PnpmExecOptions type, imports switched to ESM using createRequire(import.meta.url), spawn process error handling now guards against null/undefined exit codes.
Test Framework & Fixtures
test/index.ts, test/index.test.ts, test/fixture/pnpm-workspace.yaml, test/fixture/shrinkwrap.yaml
Tape test removed and replaced with Node.js native test, fixture isolation enabled via standalone pnpm workspace, shrinkwrap fixture cleared for regeneration during test runs.
CI Infrastructure
.github/workflows/ci.yml, .travis.yml
GitHub Actions workflow introduced with matrix testing across OS (ubuntu/macOS/windows) and Node versions (22/24), Travis CI configuration removed.
Documentation & Examples
README.md, example.js, .gitignore
Usage examples updated from CommonJS require + promise chaining to ESM import + await syntax, Travis badge replaced with npm version badge, test/fixture/pnpm-lock.yaml added to gitignore.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Hops with glee through module migration!
From CommonJS chains to async await,
GitHub Actions gleam, tests native now run,
ESM exports shine bright,
The future is modern, the future is fun! 🎉

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/modernize-esm

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

@zkochan zkochan merged commit d9dca8d into main May 8, 2026
6 of 7 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