plugins icon indicating copy to clipboard operation
plugins copied to clipboard

charlie: ESM update of auto-install

Open shellscape opened this issue 2 months ago • 2 comments

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

shellscape avatar Oct 29 '25 02:10 shellscape

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.

charliecreates[bot] avatar Oct 29 '25 02:10 charliecreates[bot]

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.

charliecreates[bot] avatar Oct 29 '25 02:10 charliecreates[bot]