Monday 9 January 2017

Does anyone know of a npm package that allows you to require a module from anywhere?

I'm looking for a package that allows you to require a module that exists anywhere in your codebase without having to know the exact path, basically:a.js ---- // this file somehow provides module "foo" b.js ---- const foo = require('foo'); // instead of '../../../lib/module/foo' This allows you to cleanly organize your project however you see fit, and to re-organize it without changing tons of require() statements.Google does this via goog.provide('moduleName'), Facebook does it via @providesModule moduleName. I don't want to use Google's because I don't like closure, and I can't find a specifically open-source version of FB's (it's embedded in fbjs & libs like React & Relay)Possible solutions might be generating the import maps for browserify, flow, etc, or symlinking tons of files in node_modules

Submitted January 10, 2017 at 02:45AM by VoiceNGO

No comments:

Post a Comment