require-stub

2.2.4 • Public • Published

Broswer require()

Provide synchronous 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.

Precautions

  • Don’t use in production: dynamic evals proved to be ~3x slower than browserified code. But it is good for perf testing.

Similar efforts

  • breq — resolves relative requirements.
  • TKRequire — resolves relative requirements.
  • smoothie.js — resolves relative requirements.

Best wishes,

Deema.

NPM

Package Sidebar

Install

npm i require-stub

Weekly Downloads

6

Version

2.2.4

License

Unlicensed

Last publish

Collaborators

  • dfcreative