README
resolve-shimify
Custom resolve for browserify.
Here are two typical cases where this plugin comes in handy:
- Make
require('react')
equal torequire('react/dist/react.js')
, even for react components installed innode_modules
, most of them not specifying a browser-filed inpackage.json
- Make symlinks resolved to their real paths, so that they can be treated as local packages and transforms from
package.json
may be applicable. You can use realpathify, which is based on this plugin.
This plugin hacks a private property of the browserify instance (b._bresolve
).
It does not transform file contents, but makes twists to the behaviour of resolving the module paths.
So it is much more faster than applying a global transform.
Usage
var browserify = require('browserify');
var shimify = require('resolve-shimify');
browserify(opts)
.plugin(shimify, { react: 'react/dist/react.js' })
;
b.plugin(shimify, shimFn)
shimFn(module)
Type: Function
Return: String
, undefined
This function is called before resolving, to transform module
to some other value to resolve.
If the returned value is falsy
, the original module
value will be used.
b.plugin(shimify, shims)
shims
Type: Object
A map for transforming module
.
Each key must be either an absolute path or a module path.