Registry / http-networking / requisite

requisite

JSON →
library0.1.3jsnpmunverified

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.

npm install requisite
INSTALL
IMPORT
SIG · REQUISITE
R
requisite
http-networkingjavascriptv0.1.3
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

requisite
✓ const requisite = require('requisite');
✗ import requisite from 'requisite';
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.
requisite.json
✓ const requisite = require('requisite'); requisite().use(requisite.json());
✗ import { json } from 'requisite';
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.
CLI Usage
✓ npm install -g requisite requisite module.js -o bundle.js
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.

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.

/* Assume 'entry.js' and 'async-bar.js' exist in the same directory entry.js: console.log(require('./foo')) require('./async-bar', function(bar) { console.log(bar) }) foo.js: module.exports = 'foo'; async-bar.js: module.exports = 'bar'; */ // 1. Install requisite globally // npm install -g requisite // 2. Create the example files (e.g., entry.js, foo.js, async-bar.js) // 3. Bundle the entry point using the CLI const { execSync } = require('child_process'); const fs = require('fs'); const path = require('path'); const projectDir = path.join(__dirname, 'requisite-quickstart-project'); if (!fs.existsSync(projectDir)) { fs.mkdirSync(projectDir); } fs.writeFileSync(path.join(projectDir, 'entry.js'), ` console.log(require('./foo')); require('./async-bar', function(bar) { console.log(bar); // This will be loaded asynchronously }); `); fs.writeFileSync(path.join(projectDir, 'foo.js'), ` module.exports = 'foo'; `); fs.writeFileSync(path.join(projectDir, 'async-bar.js'), ` module.exports = 'bar'; `); console.log('Running Requisite CLI...'); try { const output = execSync(`requisite entry.js -o bundle.js`, { cwd: projectDir }).toString(); console.log('CLI Output:', output); const bundledCode = fs.readFileSync(path.join(projectDir, 'bundle.js'), 'utf8'); console.log('\n--- Generated Bundle (bundle.js) ---\n', bundledCode.substring(0, 500), '...\n'); console.log('\nBundle created successfully in', path.join(projectDir, 'bundle.js')); // To run the bundled code (requires a browser environment or Node with custom require setup) // This snippet only generates the bundle; executing it is outside simple Node.js scope. } catch (error) { console.error('Error running Requisite CLI:', error.message); if (error.stderr) console.error('Stderr:', error.stderr.toString()); if (error.stdout) console.error('Stdout:', error.stdout.toString()); } // Clean up generated files (optional) // fs.unlinkSync(path.join(projectDir, 'bundle.js')); // fs.unlinkSync(path.join(projectDir, 'entry.js')); // fs.unlinkSync(path.join(projectDir, 'foo.js')); // fs.unlinkSync(path.join(projectDir, 'async-bar.js')); // fs.rmdirSync(projectDir);
requisite --version
Debug
Known issues
breakingRequisite 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.
fix
Migrate to a modern bundler like Webpack, Rollup, or Vite, or convert ES modules to CommonJS before bundling with Requisite.
affects: >=1.0.0
gotchaRequisite'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.
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.
affects: >=1.0.0
deprecatedThe 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.
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.
affects: <=1.19.17
Errors
Common errors & fixes
Error: Cannot find module 'module-name'
Requisite could not resolve a `require()` path to an existing file or an installed npm module within its search paths.
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.
SyntaxError: require is not defined
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.
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.
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module
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"`.
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.
Upgrade
Version history
0.1.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
requisite — npm install requisite · libregistry