plugins
plugins copied to clipboard
charlie: ESM update of auto-install
Update the auto-install package to ESM following this playbook: .charlie/playbooks/upgrade-plugin-to-esm-only.md
Expand this to see my work.
- Verified
packages/auto-install/src/index.tsis ESM-only (import/export default) with norequire/module.exports. - Refactored imports to
node:specifiers; confirmedresolveIdcorrectly filtersinstalledfrompkg.dependenciesplusnode:modulebuiltinModules. - Inlined
RollupAutoInstallOptionsinsrc/index.ts(withmanager?: 'npm'|'yarn'|'pnpm'and test-onlycommands); removed legacytypes/. - Updated
packages/auto-install/package.jsonfor ESM-only:"type": "module",exportsto./dist/index.jsand./dist/index.d.ts,engines.node: >=20.19.0,peerDependencies.rollup: >=4.0.0, and scripts usingtsc/vitest. - Removed CJS-era build config by deleting
rollup.config.mjs; pointedtsconfig.jsonat../../.config/tsconfig.plugin.json. - Cleaned tests: verified Vitest config (
../../.config/vitest.config.mts) and ESM fixtures (test/fixtures/input.jswithimport 'node-noop'); removed legacy AVA tests/snapshots. - Aligned TypeScript 5.9 workspace settings;
tsc --project tsconfig.jsonsucceeds withmoduleResolution: "bundler"from the shared config. - Built ESM artifacts:
dist/index.jsusesnode:imports and default-exportsautoInstall;dist/index.d.tsexposesRollupAutoInstallOptionsandautoInstall(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.jsoninherited bytsconfig.plugin.json.
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.