0.0.4 • Published 6 years ago

@mrjs/pkgsolver v0.0.4

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

pkgsolver - Smarter Resolver for your NodeJS project !

Description

Default Node only load modules from node_modules folder. This plugin can autoload all package.json files recursively, so you can named your library to require/import every where from your workspace. For example, instead of using complex relative paths like ../../../../shared/utils you can place use @shared/utils. It will allow you to work faster since you won't need to calculate how many levels of directory you have to go up before accessing the file.

{
    "name": "@shared",
    "main": "./"
}
// Use this:
import MyUtilFn from '@shared/utils';
// Instead of that:
import MyUtilFn from '../../../../shared/utils';

// And it also work with require calls
// Use this:
const MyUtilFn = require('@shared/utils');
// Instead of that:
const MyUtilFn = require('../../../../shared/utils');

Getting started

Install the plugin

$ npm install --save-dev @mrjs/pkgsolver

Specify the plugin in your .babelrc .Here's an example:

{
  "plugins": [
    ["@mrjs/pkgsolver"]
  ]
}

or custom root folder for scan package.json

{
  "plugins": [
    ["@mrjs/pkgsolver", {
      "root": ["../packages/"],
    }]
  ]
}

License

MIT, see LICENSE for details.

Are you also using it? Send a PR!

0.0.4

6 years ago

0.0.3

6 years ago