{"id":13941,"library":"requisite","title":"Requisite JavaScript Bundler","description":"Requisite is a JavaScript bundler that focuses on compiling client-side code and templates, primarily utilizing the CommonJS module format. As of version 1.19.17, it enables developers to structure browser-side applications using Node.js-style `require` statements, supporting both synchronous and asynchronous module loading for optimized performance. Key differentiators include automatic compiler detection for various languages, a flexible API for programmatic use, lazy asset loading, and integration with `connect`/`express` for rapid development. It also offers a command-line interface for straightforward bundling tasks and good source map support. It explicitly directs users interested in ES module support to an alternative project, Handroll, indicating its dedicated focus on CommonJS and an older paradigm for module management. Requisite's release cadence appears to be slow or ceased, given its long-standing version and the explicit guidance away from it for modern ES module workflows.","status":"maintenance","version":"1.19.17","language":"javascript","source_language":"en","source_url":"https://github.com/zeekay/requisite","tags":["javascript","analysis","asset","browser","bundle","commonjs","compress","inception","minify"],"install":[{"cmd":"npm install requisite","lang":"bash","label":"npm"},{"cmd":"yarn add requisite","lang":"bash","label":"yarn"},{"cmd":"pnpm add requisite","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Requisite is a CommonJS module and should be imported using `require()`. It does not support ES module `import` syntax. The main export is a function that typically initiates the bundling process.","wrong":"import requisite from 'requisite';","symbol":"requisite","correct":"const requisite = require('requisite');"},{"note":"Plugins like `json()` are exposed as properties on the main `requisite` export and are used to configure the bundler's processing pipeline. They are not directly importable as named ES modules.","wrong":"import { json } from 'requisite';","symbol":"requisite.json","correct":"const requisite = require('requisite');\nrequisite().use(requisite.json());"},{"note":"The primary intended usage of Requisite is via its command-line interface, typically after a global installation. Programmatic usage is available but less prominently featured in documentation.","symbol":"CLI Usage","correct":"npm install -g requisite\nrequisite module.js -o bundle.js"}],"quickstart":{"code":"/*\n  Assume 'entry.js' and 'async-bar.js' exist in the same directory\n  entry.js:\n  console.log(require('./foo'))\n  require('./async-bar', function(bar) {\n      console.log(bar)\n  })\n\n  foo.js:\n  module.exports = 'foo';\n\n  async-bar.js:\n  module.exports = 'bar';\n*/\n\n// 1. Install requisite globally\n// npm install -g requisite\n\n// 2. Create the example files (e.g., entry.js, foo.js, async-bar.js)\n\n// 3. Bundle the entry point using the CLI\nconst { execSync } = require('child_process');\nconst fs = require('fs');\nconst path = require('path');\n\nconst projectDir = path.join(__dirname, 'requisite-quickstart-project');\n\nif (!fs.existsSync(projectDir)) {\n  fs.mkdirSync(projectDir);\n}\n\nfs.writeFileSync(path.join(projectDir, 'entry.js'), `\nconsole.log(require('./foo'));\nrequire('./async-bar', function(bar) {\n    console.log(bar); // This will be loaded asynchronously\n});\n`);\nfs.writeFileSync(path.join(projectDir, 'foo.js'), `\nmodule.exports = 'foo';\n`);\nfs.writeFileSync(path.join(projectDir, 'async-bar.js'), `\nmodule.exports = 'bar';\n`);\n\nconsole.log('Running Requisite CLI...');\ntry {\n  const output = execSync(`requisite entry.js -o bundle.js`, { cwd: projectDir }).toString();\n  console.log('CLI Output:', output);\n  const bundledCode = fs.readFileSync(path.join(projectDir, 'bundle.js'), 'utf8');\n  console.log('\\n--- Generated Bundle (bundle.js) ---\\n', bundledCode.substring(0, 500), '...\\n');\n  console.log('\\nBundle created successfully in', path.join(projectDir, 'bundle.js'));\n\n  // To run the bundled code (requires a browser environment or Node with custom require setup)\n  // This snippet only generates the bundle; executing it is outside simple Node.js scope.\n\n} catch (error) {\n  console.error('Error running Requisite CLI:', error.message);\n  if (error.stderr) console.error('Stderr:', error.stderr.toString());\n  if (error.stdout) console.error('Stdout:', error.stdout.toString());\n}\n\n// Clean up generated files (optional)\n// fs.unlinkSync(path.join(projectDir, 'bundle.js'));\n// fs.unlinkSync(path.join(projectDir, 'entry.js'));\n// fs.unlinkSync(path.join(projectDir, 'foo.js'));\n// fs.unlinkSync(path.join(projectDir, 'async-bar.js'));\n// fs.rmdirSync(projectDir);\n","lang":"javascript","description":"This quickstart demonstrates the core CLI functionality of Requisite by bundling a simple CommonJS module with an asynchronous dependency into a single output file. It shows how Requisite processes `require` statements and handles lazy loading, creating necessary project files and then invoking the bundler."},"warnings":[{"fix":"Migrate to a modern bundler like Webpack, Rollup, or Vite, or convert ES modules to CommonJS before bundling with Requisite.","message":"Requisite explicitly does not support ES (ECMAScript) module syntax (`import`/`export`). For projects requiring modern JavaScript module features, the README directs users to 'Handroll' or similar contemporary bundlers. Attempting to bundle ES modules with Requisite will lead to syntax errors.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Always be mindful of the `require` signature within Requisite-bundled code. If asynchronous loading is not desired, ensure `require` is used synchronously without a callback.","message":"Requisite's `require` implementation supports an optional callback for asynchronous module loading, which differs from standard synchronous CommonJS `require` in Node.js. Developers accustomed to purely synchronous `require` behavior in Node.js might find this behavior unexpected in browser contexts.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"For new projects, consider modern bundlers that fully support ES Modules and the latest JavaScript standards. For existing projects using Requisite, ensure your Node.js environment and dependencies are compatible with its older runtime requirements.","message":"The package targets older Node.js versions (>=0.6.0) and uses CommonJS extensively, a paradigm that is less prevalent for new frontend projects, which generally favor ES Modules. This may lead to compatibility issues with newer JavaScript features or development environments.","severity":"deprecated","affected_versions":"<=1.19.17"}],"env_vars":null,"search_vec":"'1.19.17':28 'also':80 'altern':107 'analysi':152 'api':64 'appear':127 'applic':37 'asset':69,153 'asynchron':47 'automat':56 'away':143 'browser':35,154 'browser-sid':34 'bundl':89,155 'bundler':3,8 'cadenc':126 'ceas':132 'client':14 'client-sid':13 'code':16 'command':84 'command-lin':83 'commonj':22,115,156 'compil':12,57 'compress':157 'connect':74 'dedic':112 'detect':58 'develop':31,78 'differenti':54 'direct':98 'enabl':30 'es':102,148 'explicit':97,141 'express':75 'flexibl':63 'focus':10,113 'format':24 'given':133 'good':92 'guidanc':142 'handrol':109 'incept':158 'includ':55 'indic':110 'integr':72 'interest':100 'interfac':86 'javascript':2,7,151 'key':53 'languag':61 'lazi':68 'line':85 'load':49,70 'long':136 'long-stand':135 'manag':122 'map':94 'minifi':159 'modern':147 'modul':23,48,103,121,149 'node.js':39 'offer':81 'older':118 'optim':51 'paradigm':119 'perform':52 'primarili':19 'programmat':66 'project':108 'rapid':77 'releas':125 'requir':41 'requisit':1,4,123 'side':15,36 'slow':130 'sourc':93 'stand':137 'statement':42 'straightforward':88 'structur':33 'style':40 'support':43,95,104 'synchron':45 'task':90 'templat':18 'use':38,67 'user':99 'util':20 'various':60 'version':27,138 'workflow':150","created_at":"2026-04-20T01:57:06.538040+00:00","updated_at":"2026-04-20T01:57:06.538040+00:00","problems":[{"fix":"Ensure the required module exists at the specified relative path or is correctly installed in `node_modules`. Check `requisite --base` option if paths are relative to a different base directory.","cause":"Requisite could not resolve a `require()` path to an existing file or an installed npm module within its search paths.","error":"Error: Cannot find module 'module-name'"},{"fix":"Ensure the Requisite bundle includes its prelude (`--no-prelude` option is not used) and is executed in the target environment (e.g., browser) where the `require` function is made globally available by the bundler.","cause":"This error typically occurs when bundled code, which relies on Requisite's custom `require` prelude, is run in an environment (e.g., a simple browser script tag) where the prelude hasn't been injected or correctly executed.","error":"SyntaxError: require is not defined"},{"fix":"Ensure all files intended for bundling with Requisite are pure CommonJS modules, or transpile ES Modules to CommonJS before feeding them to Requisite. Alternatively, switch to a bundler that supports ES Modules.","cause":"You are attempting to `require()` an ES Module file, which Requisite, as a CommonJS-focused bundler, does not natively support. Node.js environments will throw this error when a CommonJS `require` attempts to load an `.mjs` file or a `.js` file in a package defined as `\"type\": \"module\"`.","error":"Error [ERR_REQUIRE_ESM]: Must use import to load ES Module"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.1.3","cli_name":"requisite","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/zeekay/requisite","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/requisite","openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}