require in browser for development purposes. A convenient replacement for watchify (dynamic, no configs needed). Strives to be compliant with browserify, in that code using
require-stub is fully browserifyable.
$ npm install --save-dev require-stub
<!-- provide `reqiure` --> <script src="node_modules/require-stub/index.js"></script> <!-- use require --> <script> var assert = require("chai").assert; var Emitter = require("emitter"); </script>
If you find something doesn’t work, report a bug.
How does it work?
Via synchronous XMLHttpRequest. To resolve module paths used
package.json closest to the current page. To stub native packages is used browser-builtins. Required scripts are evaled, so to provide module scopes.
- Don’t use in production: dynamic evals proved to be ~3x slower than browserified code. But it is good for perf testing.
- breq — resolves relative requirements.
- TKRequire — resolves relative requirements.
- smoothie.js — resolves relative requirements.