0.0.1 • Published 8 years ago

global-modulize v0.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

global-modulize

Build Status

Introduction

Import a file by path is painful. Change the structure of folder likes a tragedy. So make it accessible globally.

// before
const lib = require('../../../folder/file');

// after
const gm = require('gm');
const lib = gm('lib-name');

When you move the file to another place, what you need is set the config file. Not all the files import the file.

Usage

Create a config file named .gm.js to config name and which file the name is pointing.

export default {
  root: '/',
  entries: {
    name1: './path/to/the/file1',
    name2: './path/to/the/file2',
  },
};

Then, when you want to import a file, use it like this:

const gm = require('global-modulize');
const lib1 = gm('name1');
const lib2 = gm('name2');