Splittable Bundler

4.0.0 · abandoned · verified Tue Apr 21

Splittable is a JavaScript module bundler designed for efficient code splitting, optimized bundle sizes, and dead code elimination, leveraging Closure Compiler, Babel, and Browserify under the hood. Currently at version 4.0.0, the package appears to be abandoned, with its last known publication several years ago, indicating no ongoing development or maintenance. It differentiates itself by offering a "zero-configuration" approach to advanced optimizations, aiming to produce smaller code than contemporary alternatives like Webpack and Rollup (though Rollup at the time lacked code splitting and direct CommonJS support). It supports both ES6 and CommonJS modules (with some caveats) and includes experimental JSX support. While it aims for simplicity, its reliance on Java for Closure Compiler and specific Babel configurations are key operational considerations.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to programmatically use Splittable to bundle two entry modules, `a.js` and `b.js`, into separate output bundles, including a shared `_base.js` bundle. It creates a temporary project structure, executes the bundler, and logs success or failure with warnings.

const splittable = require('splittable');
const path = require('path');
const fs = require('fs');

// Create a dummy project structure for the example
const tempDir = path.join(__dirname, 'temp_splittable_project');
const libDir = path.join(tempDir, 'lib');
const outDir = path.join(tempDir, 'out');

fs.mkdirSync(libDir, { recursive: true });
fs.mkdirSync(outDir, { recursive: true });

fs.writeFileSync(path.join(libDir, 'a.js'), 'export function sayHello() { console.log("Hello from A!"); }');
fs.writeFileSync(path.join(libDir, 'b.js'), 'import { sayHello } from "./a"; sayHello(); console.log("From B");');

console.log('Starting Splittable bundling...');
splittable({
  modules: [path.join(libDir, 'a.js'), path.join(libDir, 'b.js')],
  writeTo: outDir,
  warnings: true // Enable Closure Compiler warnings
})
.then(function(info) {
  if (info.warnings) {
    console.warn('Compilation successful with warnings:', info.warnings);
  } else {
    console.log('Compilation successful.');
  }
  console.log('Bundles written to:', outDir);
})
.catch(function(reason) {
  console.error('Compilation failed:', reason);
})
.finally(() => {
  // Clean up dummy project (optional)
  // fs.rmSync(tempDir, { recursive: true, force: true });
  // console.log('Cleaned up temporary project directory.');
});

view raw JSON →