What this thread does
Rename the workspace package and its consumer dependencies together, rewrite exact module specifiers, then typecheck and build every consuming app.
What changed
- For this rename, the dependency graph changes as well as source text: pnpm workspace links and Turborepo package boundaries depend on package manifests, checked 2026-10-28.
- Current Nx move options include
--projectName,--newProjectName,--importPathand--updateImportPath, checked 2026-10-28. This is a project move generator, not a universal package-name codemod.
How to migrate
1. Record the old and new package name, all exported subpaths, every consuming app and the existing typecheck/build commands. Use rg -n --fixed-strings '@acme/old' apps packages plus a separate search of root manifests, build configuration and CI. These are example names to replace with your actual names. 2. Change the shared package's package.json name and consumer dependency keys in dependencies, devDependencies and peerDependencies. Preserve dependency ranges intentionally. Update self-imports and workspace aliases; pnpm supports aliases, so audit dependency values as well as keys. Regenerate the lockfile with the repository's pinned pnpm and review it. Do not hand-edit lockfile internals. 3. Pick one rewrite tool from the table below. For a package-only rename, keep its directory fixed to reduce the diff. If moving an Nx project too, inspect nx generate @nx/workspace:move <destination> --projectName=<old-project> --newProjectName=<new-project> --importPath=<new-package> using your installed generator's help before applying it. Review its edits before running another transform over them. 4. Match only s === oldName || s.startsWith(oldName + '/'); rewrite the matched prefix and preserve the suffix. Handle imports, type-only imports, re-exports, literal import(), literal require() and import('...') types. Flag computed imports for review; do not guess their runtime values. Do not rename @acme/old-extra. 5. With ts-morph, load each relevant tsconfig and list the included files first. Its import API provides getModuleSpecifierValue() and setModuleSpecifier(); the export API handles re-exports. A symbol's .rename() is a different operation. With jscodeshift, start with jscodeshift -t transforms/rename-package.cjs apps packages --extensions=ts,tsx --parser=tsx --dry --print --fail-on-error; this assumes you have written that transform. Run JS files separately with the appropriate parser. The runner flags are checked 2026-10-28. 6. Update TypeScript path aliases and config strings separately. Project references contain paths: change them when directories/config paths move, not merely because a package name changes. TypeScript build mode uses tsc -b to order referenced builds. 7. Install from the updated lockfile in a clean checkout, then run the real consumer checks. For repos that define these scripts, pnpm --filter '...@acme/new' run typecheck and pnpm --filter '...@acme/new' run build select the renamed package plus dependents; pnpm filtering explains the prefix ellipsis. On Turbo, use the configured task names, e.g. turbo run build check-types, and inspect the selected task graph. Run a full workspace check once because the graph itself changed.
Versions and licences
Repository manifest snapshots, checked 2026-10-28; these are not assertions about registry dist-tags. Keep your package manager and orchestrator pinned for the rename.
| Tool | Snapshot and licence | Source |
|---|---|---|
| ts-morph | 28.0.0; MIT; checked 2026-10-28 | Official manifest |
| jscodeshift | 17.4.0; MIT; checked 2026-10-28 | Official manifest |
When to pick which
| Option | Pick when | Not for |
|---|---|---|
| Nx move generator | You actually need to relocate an Nx project and update its import path | Assuming every arbitrary config string or runtime import is covered |
| ts-morph | You need TypeScript project context and controlled source edits | Assuming one root tsconfig includes all workspace apps |
| jscodeshift | You want a file-based TS/TSX transform with previewable output | Semantic symbol resolution or automatic manifest edits |
What breaks
A consumer may still request the old name, a deep import may target a missing export, or a bundler alias may disagree with TypeScript. A successful editor rename does not prove runtime resolution. Moving directories can also break reference paths, asset paths and package exports.
What to test
Include fixtures for bare and subpath imports, type-only imports, re-exports, require, dynamic imports, unchanged relative paths and similarly prefixed packages. A second transform pass should make zero changes. Check declaration output, each app's production build, test/mocking aliases and a runtime smoke test through the public package entry points. Compare the inventory of consumers with the checks actually run.
Community evidence
- In ts-morph issue 1653 (closed on 2026-11-21 by merged PR #1699), hoodmane reported different dependency-resolution results when loading files by tsconfig versus explicit globs. This supports enumerating loaded files, not assuming the project includes everything.
- In issue 1667, jason-ha reports ESM-only export resolution trouble and proposes a workaround. It is a user report, not evidence that every current installation has that defect. Validate with your real compiler and bundler.
Pitfalls
Do not combine the rename with export redesign or dependency upgrades. Avoid a global text replacement across prose, generated output and unrelated identifiers. Preserve workspace: dependencies deliberately; an old package accidentally resolving from a registry can conceal an incomplete rename.
A prompt for your agent
Your training data may predate these APIs. Read the linked pnpm, Nx, ts-morph and jscodeshift official pages before editing; do not guess flags. Inventory consumers and all module-specifier forms. Propose a bounded, idempotent transform and fixtures, preserve subpaths, then update manifests and config. Show the diff, remaining old-name references and typecheck/build results for every consumer. Report computed imports that need a human decision.
Limits
This workflow was not executed on a monorepo. The issue reports illustrate failure modes, not independent successful end-to-end rename trials. Published external consumers need a separate release and compatibility plan; changing internal names does not migrate downstream repositories.
Started from a post by @hoodmane, packaged by the editor. Original post