1.0.12 • Published 4 years ago

babel-plugin-extension-resolver v1.0.12

Weekly downloads
32
License
MIT
Repository
github
Last release
4 years ago

current version Build Status Coverage Status Mutation testing badge semantic-release Commitizen friendly

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
import other from './other';
import another from './another';

require('./other');
require('./another');

Out:

// lib/index.js
import other from './other.node.js';
import another from './another.js';

require('./other.node.js');
require('./another.js');

Install

npm install --save babel-plugin-extension-resolver

.babelrc

{
  "plugins": ["extension-resolver"]
}

With options:

{
  "plugins": [["extension-resolver", {
    "extensions": [".cool.js", ".js"]
  }]]
}

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.

1.0.11

4 years ago

1.0.12

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago