Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zoubin/resolve-shimify
custom resolve for browserify
https://github.com/zoubin/resolve-shimify
Last synced: 8 days ago
JSON representation
custom resolve for browserify
- Host: GitHub
- URL: https://github.com/zoubin/resolve-shimify
- Owner: zoubin
- Created: 2015-07-10T05:11:23.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-07-10T07:51:07.000Z (over 9 years ago)
- Last Synced: 2024-10-29T23:56:46.619Z (20 days ago)
- Language: JavaScript
- Size: 129 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# resolve-shimify
Custom resolve for [browserify](http://npmjs.org/package/browserify).Here are two typical cases where this plugin comes in handy:
1. Make `require('react')` equal to `require('react/dist/react.js')`, even for react components installed in `node_modules`, most of them not specifying a [browser-filed](https://github.com/substack/browserify-handbook#browser-field) in `package.json`
2. Make symlinks resolved to their real paths, so that they can be treated as local packages and [transforms](https://github.com/substack/browserify-handbook#browserifytransform-field) from `package.json` may be applicable. You can use [realpathify](http://npmjs.org/package/realpathify).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
```javascript
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.