{"id":13656449,"url":"https://github.com/zeekay/requisite","last_synced_at":"2025-03-21T05:30:50.768Z","repository":{"id":3706060,"uuid":"4777490","full_name":"zeekay/requisite","owner":"zeekay","description":"🕸️ CommonJS bundler with automatic compilation, browser reload and more.","archived":false,"fork":false,"pushed_at":"2020-05-21T14:51:28.000Z","size":2142,"stargazers_count":12,"open_issues_count":20,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T22:06:52.465Z","etag":null,"topics":["browser","bundler","coffeescript","commonjs","javascript","modules"],"latest_commit_sha":null,"homepage":"","language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"jordanterry/Espresso-Examples","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zeekay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-06-25T03:31:46.000Z","updated_at":"2024-02-10T12:44:10.000Z","dependencies_parsed_at":"2022-09-16T04:41:44.793Z","dependency_job_id":null,"html_url":"https://github.com/zeekay/requisite","commit_stats":null,"previous_names":[],"tags_count":188,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeekay%2Frequisite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeekay%2Frequisite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeekay%2Frequisite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeekay%2Frequisite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zeekay","download_url":"https://codeload.github.com/zeekay/requisite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244130274,"owners_count":20402753,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser","bundler","coffeescript","commonjs","javascript","modules"],"created_at":"2024-08-02T05:00:20.678Z","updated_at":"2025-03-21T05:30:50.353Z","avatar_url":"https://github.com/zeekay.png","language":"CoffeeScript","funding_links":[],"categories":["CoffeeScript"],"sub_categories":[],"readme":"# requisite\n\n[![npm][npm-img]][npm-url]\n[![build][build-img]][build-url]\n[![dependencies][dependencies-img]][dependencies-url]\n[![downloads][downloads-img]][downloads-url]\n[![license][license-img]][license-url]\n[![chat][chat-img]][chat-url]\n\n\u003e Cosmic JavaScript bundling\n\n#### Want ES module support? See [Handroll](https://github.com/zeekay/handroll).\n\n## Introduction\nRequisite bundles client-side code and templates. It features asynchronous\nmodule loading for optimal performance of large applications, automatic compiler\ndetection for several languages and comes with a\n[connect][connect]/[express][express] middleware for rapid development.\n\n## Features\n- Use CommonJS modules in the browser.\n- Customizable compiler/preprocessors.\n- Simple API for programmatic usage.\n- Lazy asset loading.\n- Resolves relative as well as npm modules.\n- Command line tool for bundling simple projects.\n- Good Source map support.\n\n## Install\n```bash\nnpm install -g requisite\n```\n\n## Modules\nRequiste allows you to structure your code using [CommonJS (Node.js)\nmodules][commonjs]. From a given starting point or entry module, requisite will\ntrace your application's dependencies and bundle all `require`'ed modules\ntogether. Requiste's `require` supports asynchronous loading of assets/modules\nwhen an optional callback argument is provided.\n\n```javascript\n// foo.js\nmodule.exports = 'foo';\n\n// async-bar.js\nmodule.exports = 'bar'\n\n// entry.js\nconsole.log(require('./foo'))  // 'foo'\nrequire('./async-bar', function(bar) {\n    console.log(bar) // 'bar'\n})\n```\n\nThis compiles down to:\n\n```javascript\n// ...prelude, defining require, etc.\n\nrequire.define('/foo', function (module, exports, __dirname, __filename) {\n    module.exports = 'foo';\n})\n\nrequire.define('/main', function (module, exports, __dirname, __filename) {\n    console.log(require('/foo'));\n    require('/async-bar', function(bar) {\n        console.log(bar);\n    })\n})\n```\n\nNote how `async-bar.js` is missing from the bundle, as it's loaded at runtime.\n\nIf you are writing a module that can be used both client/server side you can\ndefine the [`browser`](browser-field) field in your package.json and finetune which bits will be\nbundled for the client.\n\n## Usage\n### CLI\n```bash\n› requisite\n\nUsage: requisite [options] [files]\n\nOptions:\n\n  -h, --help                   display this help\n  -v, --version                display version\n  -a, --async                  prelude should support async requires\n  -b, --bare                   compile without a top-level function wrapper\n  -d, --dedupe                 deduplicate modules (when multiple are specified)\n  -e, --export \u003cname\u003e          export module as \u003cname\u003e\n  -i, --include \u003cmodule\u003e       additional module to include, in \u003crequire as\u003e:\u003cpath to module\u003e format\n  -g, --global                 global require\n  -m, --minify                 minify output\n      --minifier               minifier to use\n  -o, --output \u003cfile\u003e          write bundle to file instead of stdout, {} may be used as a placeholder\n  -p, --prelude \u003cfile\u003e         file to use as prelude\n      --no-prelude             exclude prelude from bundle\n      --no-source-map          disable source maps\n      --prelude-only           only output prelude\n  -s, --strict                 add \"use strict\" to each bundled module\n      --strip-debug            strip `alert`, `console`, `debugger` statements\n  -w, --watch                  write bundle to file and and recompile on file changes\n  -x, --exclude \u003cregex\u003e        regex to exclude modules from being parsed\n      --base                   path all requires should be relative to\n\nExamples:\n\n  # bundle javascript file and all it's dependencies\n  $ requisite module.js -o bundle.js\n\n  # bundle several modules, appending .bundle.js to output\n  $ requisite *.js -o {}.bundle.js\n```\n\n#### Examples\nBundle a javascript file and all it's dependencies:\n```\n$ requisite module.js -o bundle.js\n```\n\nCreate several bundles, appending `.bundle.js` to each entry module's name:\n```\n$ requisite *.js -o {}.bundle.js\n```\n\nCreate a single shared bundle (to leverage caching in browser) and individual\nbundles for each page containing just the additional modules necessary for each:\n```\n$ requisite --dedupe main.js page1.js page2.js -o {}.bundle.js\n```\n\nYou'd then use the bundle across the pages of your site like so:\n```javascript\n// page1.js\n\u003cscript src=\"main.bundle.js\"\u003e\n\u003cscript src=\"page1.bundle.js\"\u003e\n\n// page2.js\n\u003cscript src=\"main.bundle.js\"\u003e\n\u003cscript src=\"page2.bundle.js\"\u003e\n\n// page3.js\n\u003cscript src=\"main.bundle.js\"\u003e\n\u003cscript src=\"page3.bundle.js\"\u003e\n```\n\n### API\nIf you want more fine-grained control over requisite you can require it in your\nown projects and use it directly.\n\n```javascript\n    require('requisite').bundle({\n        entry: __dirname + '/entry.js',\n    }, function(err, bundle) {\n        fs.writeFileSync('app.js', bundle.toString())\n    });\n```\n\n### Middleware\nFor development it can be useful to serve bundles up dynamically, and a connect\nmiddleware is provided for exactly this purpose. Express example:\n\n```javascript\n  app.use('/js/app.js', require('requisite').middleware({\n    entry: __dirname + '/entry.js'\n  }))\n```\n\nWhich would make your bundle available as `http://host/js/main.js`.\n\n## License\n[MIT][license-url]\n\n[browser-field]: https://gist.github.com/defunctzombie/4339901\n[coffeescript]:  http://coffeescript.org\n[commonjs]:      http://nodejs.org/docs/latest/api/modules.html#modules_modules\n[connect]:       http://www.senchalabs.org/connect/\n[express]:       http://expressjs.com/\n[jade]:          http://jade-lang.com\n\n[build-img]:        https://img.shields.io/travis/zeekay/requisite.svg\n[build-url]:        https://travis-ci.org/zeekay/requisite\n[chat-img]:         https://badges.gitter.im/join-chat.svg\n[chat-url]:         https://gitter.im/zeekay/hi\n[coverage-img]:     https://coveralls.io/repos/zeekay/requisite/badge.svg?branch=master\u0026service=github\n[coverage-url]:     https://coveralls.io/github/zeekay/requisite?branch=master\n[dependencies-img]: https://david-dm.org/zeekay/requisite.svg\n[dependencies-url]: https://david-dm.org/zeekay/requisite\n[downloads-img]:    https://img.shields.io/npm/dm/requisite.svg\n[downloads-url]:    http://badge.fury.io/js/requisite\n[license-img]:      https://img.shields.io/npm/l/requisite.svg\n[license-url]:      https://github.com/zeekay/requisite/blob/master/LICENSE\n[npm-img]:          https://img.shields.io/npm/v/requisite.svg\n[npm-url]:          https://www.npmjs.com/package/requisite\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeekay%2Frequisite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzeekay%2Frequisite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeekay%2Frequisite/lists"}