1.5.0 • Published 9 years ago

babel-plugin-module-require v1.5.0

Weekly downloads
16
License
MIT
Repository
github
Last release
9 years ago

babel-plugin-module-require

Transform module style requires to relative requires.

So instead of writing:

const TeamStore = require('../../../../stores/TeamStore');

you can just write:

const TeamStore = require('stores/TeamStore');

which will be transformed to the code above.

Installation

$ npm install --save babel-plugin-module-require

Usage

.babelrc, package.json or anywhere else where Babel works

{
  "presets": ["es2015"],
  "plugins": [
    ["module-require", {
      "baseDir": "src",
      "ignore": []
    }]
  ]
}

Options

####baseDir:string (optional) default: root directory where package.json is located

The base directory relative to package.json where to resolve the modules

####ignore:array[string] (optional) default: []

Array of modules to ignore i.e. keep as it is.

Notes

  • This plugin will transform only module style requires which don't seem to be installed npm packages. So it will ignore relative file paths and node packages (../stores/TeamStore and fs both will stay untouched).
  • If node package is installed with the same name, that package will be prefered instead of the actual file you may refer. So be careful.

##Contributing

Issues and PRs are welcome.

1.5.0

9 years ago

1.4.4

9 years ago

1.4.3

10 years ago

1.4.2

10 years ago

1.4.1

10 years ago

1.4.0

10 years ago

1.3.1

10 years ago

1.3.0

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago