Skip to content

charlie: ESM update of auto-install #1935

Open

Description

@shellscape

Update the auto-install package to ESM following this playbook: .charlie/playbooks/upgrade-plugin-to-esm-only.md

Activity

  1. charliecreates commented on Oct 29, 2025

    @charliecreates
    Contributor
    Expand this to see my work.
    • Verified packages/auto-install/src/index.ts is ESM-only (import/export default) with no require/module.exports.
    • Refactored imports to node: specifiers; confirmed resolveId correctly filters installed from pkg.dependencies plus node:module builtinModules.
    • Inlined RollupAutoInstallOptions in src/index.ts (with manager?: 'npm'|'yarn'|'pnpm' and test-only commands); removed legacy types/.
    • Updated packages/auto-install/package.json for ESM-only: "type": "module", exports to ./dist/index.js and ./dist/index.d.ts, engines.node: >=20.19.0, peerDependencies.rollup: >=4.0.0, and scripts using tsc/vitest.
    • Removed CJS-era build config by deleting rollup.config.mjs; pointed tsconfig.json at ../../.config/tsconfig.plugin.json.
    • Cleaned tests: verified Vitest config (../../.config/vitest.config.mts) and ESM fixtures (test/fixtures/input.js with import 'node-noop'); removed legacy AVA tests/snapshots.
    • Aligned TypeScript 5.9 workspace settings; tsc --project tsconfig.json succeeds with moduleResolution: "bundler" from the shared config.
    • Built ESM artifacts: dist/index.js uses node: imports and default-exports autoInstall; dist/index.d.ts exposes RollupAutoInstallOptions and autoInstall(opts?: RollupAutoInstallOptions): Plugin.
    • Ran Vitest twice via vitest --config ../../.config/vitest.config.mts run: 5 files, 6 tests passed (0 failures) with expected "installing node-noop..." stdout; noted a non-blocking TypeScript warning about missing ../../.config/tsconfig.base.json inherited by tsconfig.plugin.json.
  2. charliecreates commented on Oct 29, 2025

    @charliecreates
    Contributor

    Opened PR #1936 to migrate @rollup/plugin-auto-install to ESM-only and align it with the repo’s new pattern.

    • PR: feat(auto-install)!: ESM only. Update Node and Rollup minimum versions
    • Summary: switch to tsc emit (ESM-only), convert tests to Vitest, modernize Node imports, and bump minimums (Node ≥20.19.0, Rollup ≥4).
    Changes
    • Package metadata

      • Set "type": "module".
      • Expose ESM-only via exports: "types": "./dist/index.d.ts", "import": "./dist/index.js".
      • Bump minimums: engines.node ">=20.19.0", peerDependencies.rollup ">=4.0.0".
      • Scripts: tsc-only build (prebuild: del-cli, build: tsc --project tsconfig.json); tests run on Vitest.
      • Keep rollup as a devDependency (used in tests); add del-cli.
    • TypeScript config

      • Replace package tsconfig with a symlink to .config/tsconfig.plugin.json (emits JS + d.ts to dist/).
    • Source (src/index.ts)

      • Use node: specifiers and modern Node APIs.
      • Inline and export RollupAutoInstallOptions (adds 'pnpm' to manager union and a test-only commands override).
    • Tests

      • Convert AVA → Vitest (test/*.test.ts), following the alias package pattern.
      • Drop brittle snapshots; assert on package.json/lockfile content and error types instead.
      • Ensure bundles are bundle.close()-d to avoid leaks.
    • Cleanup

      • Remove rollup.config.mjs and the preauthored types/ folder.
    Verification
    # Build (tsc emit): success — dist contains index.js, index.js.map, index.d.ts, index.d.ts.map
    $ pnpm -C packages/auto-install build
    
    # Tests (Vitest): 6 passed (5 files)
    $ pnpm -C packages/auto-install test
    
    # ESLint (scoped to the package): 0 errors
    $ pnpm exec eslint --cache packages/auto-install --ext .js,.ts,.mjs

    This is a breaking change (CJS removed); the PR title is marked accordingly. Closes #1935.

  3. shellscape commented on Feb 16, 2026

    @shellscape
    CollaboratorAuthor

    @CharlieHelps I closed the previous pull request because it was using an older version of you. Please take another crack at this with a new branch and new PR. Don't look at the old branch.

  4. charliecreates commented on Feb 16, 2026

    @charliecreates
    Contributor

    Opened PR: #1964

    Highlights:

    • Migrate @rollup/plugin-auto-install to ESM-only (v4.0.0) with updated exports/type: module + tsc-built dist.
    • Switch tests to Vitest.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions