Skip to content

chore(codemod): Modernize to ESM + bump all deps + add test suite#418

Open
csandman wants to merge 2 commits into
v5from
chore/codemod-esm-modernization
Open

chore(codemod): Modernize to ESM + bump all deps + add test suite#418
csandman wants to merge 2 commits into
v5from
chore/codemod-esm-modernization

Conversation

@csandman
Copy link
Copy Markdown
Owner

Summary

Port of the codemod ESM modernization from main to v5.

  • "type": "module" + tsconfig updated to module: nodenext / moduleResolution: nodenext / target: es2022
  • bin/cli.ts: named ESM imports throughout; createRequire / fileURLToPath polyfills for require / __dirname; typed RunTransformOptions interface; proper AnyFlags schema for meow v14; typed inquirer prompt
  • bin/crs-codemod.ts: require("./cli").run() → ESM import { run } from "./cli.js"
  • All deps bumped to current ESM-native majors: execa 9, globby 16, inquirer 13, jscodeshift 17, meow 14; devDeps: rimraf 6, typescript 6, @types/* aligned; @types/inquirer removed (types are now bundled)
  • Test suite: adds vitest + test/test:watch/test:update scripts; tests/v5.test.ts with fixture-based snapshot tests covering 5 cases (basic, aliased imports, all select variants, prop preservation, unrelated-library guard)
  • lint-staged: excludes codemod/tests/fixtures/** from oxfmt — fixture files must exactly match the transform output (jscodeshift formats JSX independently of oxfmt, and they disagree on /> placement for multi-prop elements)

Test plan

  • pnpm --filter crs-codemod test — 5/5 pass
  • pnpm --filter crs-codemod build — clean TypeScript compile
  • CI: lint, test (Node 20 & 24), zizmor all green

🤖 Generated with Claude Code

csandman and others added 2 commits May 16, 2026 00:49
- Switch `"type": "module"` and update tsconfig to `module: nodenext`
- Rewrite bin/cli.ts: named ESM imports, `createRequire`/`fileURLToPath`
  polyfills for CJS globals, typed `RunTransformOptions` interface,
  proper `AnyFlags` schema for meow, typed inquirer prompt
- bin/crs-codemod.ts: replace `require("./cli").run()` with ESM import
- Update all deps to current ESM-native majors (execa 9, globby 16,
  inquirer 13, jscodeshift 17, meow 14) and devDeps (rimraf 6,
  typescript 6, @types/* aligned)
- Add vitest + `test`/`test:watch`/`test:update` scripts
- Add tests/v5.test.ts with fixture-based snapshot tests (5 fixtures
  covering basic, aliased imports, all select variants, prop
  preservation, and unrelated-library guard)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
oxfmt reformats JSX self-closing tags to put /> on its own line, but
jscodeshift produces them inline. Fixture files must exactly reflect
the transform output, so adding them to the oxfmt lint-staged exclude.

Also corrects the preserves-other-props output fixture to match what
jscodeshift 17 actually produces (inline />).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 16, 2026

commit: e5ad56e

@github-actions
Copy link
Copy Markdown

📊 Package size report   No changes

File Before After
Total (Includes all files) 155.6 kB 155.6 kB
Tarball size 31.3 kB -0%↓31.3 kB
Unchanged files
File Size
dist/index.d.mts 20.0 kB
dist/index.d.ts 20.0 kB
dist/index.js 33.1 kB
dist/index.mjs 31.5 kB
LICENSE.md 1.1 kB
package.json 2.4 kB
README.md 47.5 kB

🤖 This report was automatically generated by pkg-size-action

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