1.1.0 • Published 2 years ago

babel-plugin-no-index-imports v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

babel-plugin-no-index-imports

This plugin can transform index imports into direct file imports.

For example, the plugin can transform imports such as

import { Homepage } from '@components';

Into either default style or named imports targeting a specific file.

import { Homepage } from '@components/Homepage';

This can/will improve tree-shaking and reduce bundle size.

Installation

yarn add -D babel-plugin-no-index-imports

Usage

Add following config in your .babelrc

{
  "plugins": [
    ["babel-plugin-no-index-imports", {
      "extensions": ["js", "jsx", "ts", "tsx"],
      "useDefaultImport": false,
      "stripFileExtension": true,
      "extractName": function(filename) {
        return filename.substr(0, filename.lastIndexOf('.'));
      },
      "selectImport": function(importName, imports, member) {
        return imports[0];
      },
      "prefixes": {
        "@components": "./src/workspaces",
        "@utils": "./src/utils"
      }
    }]
  ]
}
1.1.0

2 years ago

1.0.11

2 years ago

1.0.12

2 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago