Resolve imports to more file extensions with a babel plugin
Example
With this file structure:
src/index.js
src/other.node.js
src/other.js
src/another.js
In:
// src/index.js;; ;;
Out:
// lib/index.js;; ;;
Install
npm install --save babel-plugin-extension-resolver
.babelrc
With options:
Options
extensions
Defaults: (similar to how create-react-app does it for web)
'.node.mjs' '.mjs' '.node.js' '.js' '.node.ts' '.ts' '.node.tsx' '.tsx' '.json' '.node.jsx' '.jsx' '.node'
Warning: This overrides ALL extension resolution, notably .json
and .node
. Make sure to re-include all extensions that matter.