Webmake: CommonJS Browser Bundler

1.1.2 · maintenance · verified Sun Apr 19

Webmake is a Node.js-based module bundler designed to package CommonJS modules for use in web browsers. It aims to replicate Node.js's native module resolution logic, allowing developers to organize browser-side JavaScript code using the familiar CommonJS `require` syntax and `module.exports` pattern. Beyond standard JavaScript, it features direct support for bundling CSS and HTML files, enabling them to be `require`d as modules and injected into the DOM. The project's current stable version is 1.1.2, with its last release dating back to 2020. This extended period without updates suggests the project is in a maintenance-only mode rather than active feature development. A key differentiator for `webmake` is its strict adherence to Node.js's CommonJS module system for client-side environments, setting it apart from more modern bundlers that primarily focus on ES Modules and broader ecosystem integrations. It provides a simple CLI for bundling, generating a self-contained JavaScript file ready for browser inclusion.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates bundling a simple CommonJS application into a single file for browser execution, with visible output.

// quickstart.js (entry point)
var inc = require("./increment");
var a = 1;
var result = inc(a);
document.body.innerHTML += `
  <p>Result from bundled JS:</p>
  <pre>Incremented value: ${result}</pre>
  <p>This content was generated by a CommonJS module bundled with webmake.</p>
`;

// increment.js
var add = require("./add");
module.exports = function (val) { return add(val, 1); };

// add.js
module.exports = function () {
  var sum = 0, i = 0, args = arguments, l = args.length;
  while (i < l) sum += args[i++];
  return sum;
};

/*
To run this example:
1. Save the above as three separate files: quickstart.js, increment.js, add.js
2. Open your terminal in the same directory.
3. If not already installed, install webmake globally:
   npm install -g webmake
4. Bundle the files:
   webmake quickstart.js bundle.js
5. Create an HTML file (e.g., index.html):
   <!DOCTYPE html>
   <html lang="en">
   <head>
     <meta charset="utf-8" />
     <title>Webmake Quickstart</title>
   </head>
   <body>
     <h1>Webmake CommonJS Bundler Example</h1>
     <script src="bundle.js"></script>
   </body>
   </html>
6. Open index.html in a web browser to see the output.
*/

view raw JSON →