1.0.8 • Published 5 years ago

require-alias-node v1.0.8

Weekly downloads
2
License
ISC
Repository
-
Last release
5 years ago

require-alias-node Build Status npm.io npm.io

A tool which could set an alias for the module's path which is required in the require of nodejs or import of ES6

It's the alias of require-import-alias

Install

npm install require-alias-node

Sometimes, we may use a module with a long path to be required, and the path may contain many level, is's not very intuitive !

const component = require('../../../src/component');
const moduleA = require('../../../src/component/render/moduleA');

Now we can use this tool require-alias-node to set alias for the moduleA, is looks like:

const requireAliasNode = require('require-alias-node');
requireAliasNode.setAlias({
	'component': '../../../src/component',
	'moduleA': '../../../src/component/render/moduleA'
});
const moduleA = require('moduleA');
const moduleB = require('component/main/moduleB')'

and you can also use it with import in ES2015(set an alias is a module, and use the alias in anthor module)

setAlias

import requireAliasNode from 'require-alias-node'
requireAliasNode.setAlias({
	'component': '../../../src/component',
	'moduleA': '../../../src/component/render/moduleA'
});

using it

import component from 'component'
import moduleA from 'moduleA'
import moduleB from 'component/render/moduleB'

It's so gracefully !

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 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