Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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!
- Host: GitHub
- URL: https://github.com/chenglou/require-polyfill
- Owner: chenglou
- Created: 2017-03-22T09:21:49.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-08-16T22:18:42.000Z (about 3 years ago)
- Last Synced: 2024-10-13T11:15:49.837Z (about 1 month ago)
- Topics: browser, polyfill, require
- Language: JavaScript
- Size: 7.81 KB
- Stars: 43
- Watchers: 4
- Forks: 10
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
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).