GithubHelp home page GithubHelp logo

isabella232 / reverse-require Goto Github PK

View Code? Open in Web Editor NEW

This project forked from widgetworks/reverse-require

0.0 0.0 0.0 18 KB

Search for node modules from host project first

License: MIT License

JavaScript 100.00%

reverse-require's Introduction

reverse-require

Search for node modules from host project first

Overview

This project provides a set of methods to reverse the search order of module imports.

So instead of searching the module first and moving up the chain, we start at the top-level project and work our way down the child projects until we find the module.

When is this useful?

Imagine you have a Core library that defines a set of npm dependencies.

You reference Core in Project A and Project B to get a common set of dependencies and behaviour ๐Ÿ˜Ž

But now you want to test out how a new dependency will work in Project A. You npm link the module into Project A, fire it up and... Core still loads the old version ๐Ÿ˜

Of course! Core defines the dependency so it's installed locally to that project and linking the new version to Project A won't help.

You could link the dependency into Core but it can get a bit hairy if you have a few libraries deep. And what if you need a different set of libraries in Project B?

reverse-require lets you link a module near the base of the tree and version with your dependency modules (a little like npm dedupe but without having to define the same dependency in your package.json file).

Installation

$ npm install --save reverse-require

Usage

// Configuration:

// In the index of your project:
var ReverseRequire = require('reverse-require');
ReverseRequire.moduleRoot = __filename;

// Usage:
var rr = require('reverse-require')();
var _ = rr('lodash');

reverse-require's People

Contributors

coridyn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.