A Babel plugin that transforms module path aliases (e.g., '~/' or '@') into relative paths, allowing developers to require files relative to a configured project root. Version 1.0.2, stable but low activity. It offers a pattern-based replacement with optional basePath and overrides for multi-root projects. Unlike webpack resolve aliases or TypeScript path mapping, this works purely at the Babel transpilation step, making it suitable for Node.js CJS/ESM builds.
npm install babel-plugin-require-root-rewriteVerified import paths — ran on the pinned version, not inferred.
Configures the plugin via .babelrc to replace '~/' with relative paths from the 'src' basePath, with overrides for 'api' and 'server' directories.
Use a pattern like '^~/' or '^@/' with the caret anchor.
Set basePath to an existing directory (commonly 'src' or 'lib').
List directories (not file paths) in overrides array.
Check compatibility with your Babel version; consider alternatives like babel-plugin-module-resolver.
Provide a string pattern, e.g., '^~/'
Validate your .babelrc with a JSON linter.
Run 'npm install babel-plugin-require-root-rewrite --save-dev'
No dependency data recorded yet.