relative-import-path
Like path.relative, but for generating short require'able paths.
- Removes unnecessary
node_modules
from resolved relative paths. - Automatically converts windows style paths to POSIX.
Installation
npm install relative-import-path
API
function resolveRelativePath(from: string, to: string): string;
Examples
import { relativeImportPath } from "relative-import-path";
relativeImportPath("/a/b", "/c/d");
relativeImportPath("/a/a", "/a/b");
relativeImportPath("/a/a/a", "/a/b/a");
relativeImportPath("/a/node_modules/a/a", "/a/node_modules/b/a");
relativeImportPath("/a/node_modules/a/a", "/a/node_modules/a/b");
relativeImportPath("/a/a", "/node_modules/b");
relativeImportPath("/a/a", "/a/node_modules/b");
relativeImportPath("/a/b/c", "/a/node_modules/b");
relativeImportPath("/a/a", "/b/node_modules/b");
relativeImportPath("/a/b/c", "/b/node_modules/b");
relativeImportPath("/a/a", "/a/b/node_modules/b");
relativeImportPath("/a/node_modules/@a/a/a", "/a/node_modules/@a/b/a");
relativeImportPath("/a/node_modules/@a/a/a", "/a/node_modules/@a/a/b");
Code of Conduct
This project adheres to the eBay Code of Conduct. By participating in this project you agree to abide by its terms.