Codemod to rewrite module specifiers of TypeScript files to their full paths.
npm install @patricktree/codemod-rewrite-module-specifiers-to-full-paths@patricktree/codemod-rewrite-module-specifiers-to-full-pathsCodemod to rewrite module specifiers of TypeScript files to their full paths.
Module specifiers for relative, absolute, and "subpath" (=path alias) imports in Node.js ESM need to be "exact".
This is in contrast to Node.js CJS modules, which applied a "searching" algorithm when loading modules (see also
For example, while the following require function calls were working in Node.js CJS modules, they are not working anymore in ESM modules:
``js`
/ assuming ./some-directory/index.js is present /
require('./some-directory');
require('./some-directory/index');
Therefore, migrating CJS code to ESM code involves rewriting every module specifier to its full path.
Doing this by hand is tedious and error-prone.
This package is a codemod which consumes a TypeScript configuration file and rewrites all relative, absolute, and path alias imports to their full paths.
`bash
npx @patricktree/codemod-rewrite-module-specifiers-to-full-paths --help