Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/chenglou/require-polyfill

Make `require` work in browsers, at runtime. No code bundling needed!
https://github.com/chenglou/require-polyfill

browser polyfill require

Last synced: 17 days ago
JSON representation

Make `require` work in browsers, at runtime. No code bundling needed!

Awesome Lists containing this project

README

        

# Require Polyfill

This simple script is inspired by [require1k](http://stuk.github.io/require1k/), with a few flaws fixed (works with npm3, reads package.json's `main` field, etc.).

## Usage

Drop it into a script tag like so:

```js

```

Where `data-project-root` is where `node_modules` is located.

Tada! All your js files' `require` statements will work! No watcher, no code bundling, no hassle.

**Note**: This is only meant to be used as a development time convenience.

**Note2**: On browsers like Chrome that disallow cross origin requests, we can't load directly from the file system. Start a local server in that case. Alternatively, try Safari or Firefox!

## Known Issues

- Doesn't polyfill the node.js libraries. So e.g. `require('fs')` would fail.

- Doesn't support code splitting. Kidding, it supports all the code splitting.

- Doesn't have a logo (TODO: create an entire community around this script).