Registry / web-framework / modulator

modulator

JSON →
library1.1jsnpmunverified

Modulator is a legacy JavaScript build tool designed to bundle Node.js CommonJS modules for execution in non-CommonJS environments, primarily web browsers. It achieves this by creating a shallow representation of the filesystem and a dummy CommonJS module API, outputting everything into a single source file. It also supports optional minification using UglifyJS. The package is currently at version 0.1.0, with its last known activity dating back to 2011. Due to its age, it predates modern JavaScript module systems like ESM and contemporary bundlers such as Webpack, Rollup, or esbuild. Its key differentiator at the time was its simplicity and direct use for browser compatibility of Node.js modules, without requiring complex build configurations or additional binaries.

npm install modulator
INSTALL
IMPORT
SIG · MODULATOR
M
modulator
web-frameworkjavascriptv1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

Modulator
const Modulator = require('modulator');
import Modulator from 'modulator';
Modulator is a CommonJS-only package. Attempting to import it using ES module syntax will result in errors in modern Node.js environments without a CJS wrapper.
[apiName] (e.g., myBuild)
const myBuild = window.myBuildName; // Or this.myBuildName after script inclusion
import myBuild from './output.js';
Bundles generated by Modulator expose their API on the global `window` or `this` object, using the `apiName` property specified during the build (e.g., `myBuildName`). Direct ES module imports of the generated bundle are not supported.
require (via api object)
const moduleFoo = myBuild.require('moduleFoo');
const moduleFoo = require('moduleFoo'); // In browser scope
Within the browser, modules bundled by Modulator are accessed via the `require` method exposed on the global API object (e.g., `myBuild.require`), not through a global `require` function.

This example demonstrates how to use Modulator as a Node.js build tool to bundle CommonJS modules into a single JavaScript file suitable for browser execution, including creating dummy source files for a runnable example.

const Modulator = require('modulator'); const path = require('path'); const projectRoot = __dirname; // A dummy source file for the example // In a real scenario, this would be part of your project structure const sourceContent = ` const moduleFoo = require('moduleFoo'); const scriptBar = require('./scriptBar'); exports.foo = moduleFoo; exports.bar = scriptBar; exports.version = '1.0.0'; `; // Create dummy files for the example to make it runnable require('fs').writeFileSync(path.join(projectRoot, 'source.js'), sourceContent); require('fs').mkdirSync(path.join(projectRoot, 'node_modules', 'moduleFoo'), { recursive: true }); require('fs').writeFileSync(path.join(projectRoot, 'node_modules', 'moduleFoo', 'index.js'), 'exports.name = "moduleFoo";'); require('fs').writeFileSync(path.join(projectRoot, 'scriptBar.js'), 'exports.name = "scriptBar";'); const build = new Modulator({ name: 'myBuild', main: './source.js', from: projectRoot, write: path.join(projectRoot, 'output.js'), uglify: path.join(projectRoot, 'output-min.js'), // Requires 'uglify-js' to be installed separately header: '//myBuild generated on ' + new Date().toISOString(), footer: '//End of myBuild', apiName: 'myBuildApi' }); build.compile(); console.log('Build completed. Check output.js and output-min.js (if uglify-js is installed).');
Debug
Known issues
breakingModulator is an abandoned package (last activity 2011) and provides no support for ES Modules (ESM). It exclusively handles CommonJS (CJS) syntax. Using it in modern JavaScript projects that rely on `import`/`export` syntax will lead to compilation errors or unexpected behavior.
fix
Migrate to a modern bundler like Webpack, Rollup, Parcel, esbuild, or Vite, which natively support ESM and CJS interop, along with many other contemporary features.
affects: >=0.1.0
gotchaThe bundled output from Modulator relies on global variables (e.g., `window.myBuildApi`) to expose its API in the browser. This approach is generally considered an anti-pattern in modern web development, which favors explicit module imports and encapsulated scopes.
fix
If legacy browser support is a strict requirement, ensure the global namespace is managed carefully. For new projects, adopt modern module loaders or bundlers that create isolated module scopes.
affects: >=0.1.0
gotchaModulator lacks active maintenance, meaning there will be no updates for security vulnerabilities, bug fixes, or compatibility with newer JavaScript language features (e.g., async/await, optional chaining). Relying on it for production applications carries significant risk.
fix
Strongly consider replacing Modulator with a actively maintained and secure bundling solution that supports modern JavaScript and actively addresses security concerns.
affects: >=0.1.0
deprecatedThe entire methodology of Modulator (manually bundling CJS for browsers) has been superseded by a rich ecosystem of sophisticated bundlers. Its use is deprecated in favor of tools like Webpack, Rollup, Parcel, esbuild, or Vite, which offer superior performance, features (tree-shaking, code splitting, HMR), and ecosystem support.
fix
Investigate and migrate to a contemporary JavaScript bundler to benefit from modern tooling, better developer experience, and optimized production builds.
affects: >=0.1.0
Upgrade
Version history
1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources