{"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.","language":"javascript","status":"maintenance","last_verified":"Sun Apr 19","install":{"commands":["npm install requisite"],"cli":{"name":"requisite","version":null}},"imports":["const requisite = require('requisite');","const requisite = require('requisite');\nrequisite().use(requisite.json());","npm install -g requisite\nrequisite module.js -o bundle.js"],"auth":{"required":false,"env_vars":[]},"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}