Skip to content

Makes requiring files deep in your node module easy and safe from refactoring

License

Notifications You must be signed in to change notification settings

patrickhulce/generate-export-aliases

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

generate-export-aliases

NPM Package Build Status Coverage Status Commitizen friendly Dependencies

Generates additional files to make requiring files deep in your node module easy and safe from refactoring.

Usage

Save generate-export-aliases as a dev dependency in your package.json.

npm i -D generate-export-aliases

Add a prepublish hook and the exports you wish to alias to the config section of your package.json under exportAliases. For example, if you wanted to alias the myHelper.js file in the following directory structure...

Example Folder Structure

├── LICENSE
├── README.md
├── package.json
├── lib
│   ├── fileA.js
│   ├── fileB.js
│   ├── fileC.js
│   └── shared
│       ├── myHelper.js
│       └── otherHelper.js

package.json

{
  "name": "my-fantastic-library",
  "scripts": {
    "prepublish": "generate-export-aliases"
  },
  "config": {
    "exportAliases": {
      "exposed-helper": "./lib/shared/myHelper.js"
    }
  }
}

Requiring Your Alias

const exposedHelper = require('my-fantastic-library/exposed-helper')
const exposedHelperOriginal = require('my-fantastic-library/lib/shared/myHelper.js')
exposedHelper === exposedHelperOriginal // true

Inspiration

lodash's build process

About

Makes requiring files deep in your node module easy and safe from refactoring

Resources

License

Stars

Watchers

Forks

Packages

No packages published