Resolve file by path and extensions
yarn add file-resolve
# or
npm i file-resolve
import fileResolve from "file-resolve";
fileResolve("file/path"); // file/path/index.ts
fileResolve.extensions([".css"])("file/path"); // file/path/index.css
interface fileResolve {
(p: string): string;
extensions(extensions: string[]): any; // default [".js", ".jsx", ".ts", ".tsx"]
}