A Babel plugin (v1.1.1) that rewrites import, export from, require() and dynamic import() paths to custom destinations, primarily used for mocking in tests. Last updated in 2017, it supports regex-based redirects, extra function handling, and global replacements. Unlike module aliases or webpack resolve aliases, this operates at the Babel AST level, allowing fine-grained control per file. Requires Node >=4 and babel 6/7.
npm install babel-plugin-import-redirectVerified import paths — ran on the pinned version, not inferred.
Shows basic plugin setup with root and redirect map, and how source code changes.
Add 'syntax-dynamic-import' to plugins array before 'import-redirect'.
Use double backslashes (e.g., '\\.css$' for .css files).
Ensure no code expects the removed import, or use a mock file instead.
Run npm install --save-dev babel-plugin-import-redirect
Include @babel/plugin-transform-runtime or use @babel/polyfill
No dependency data recorded yet.