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.
npm install splittableVerified import paths — ran on the pinned version, not inferred.
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.
Ensure Java Development Kit (JDK) or Java Runtime Environment (JRE) is installed and its `bin` directory is included in your system's PATH environment variable.
Configure your Babel presets to explicitly set `modules: false` for ES6 module transformations. Example: `['es2015', { loose: true, modules: false }]`.Include a Promise polyfill script (e.g., `<script src="path/to/PJs.min.js"></script>`) before loading your Splittable bundles in HTML for environments without native Promises.
Before any `System.import` calls, define `System.baseURL = '/path/to/your/bundles/';` where `/path/to/your/bundles/` is the web-accessible directory containing `_base.js` and other generated bundles.
Avoid cyclic dependencies in your CommonJS modules. Test NPM modules thoroughly for compatibility. Use `require()` for NPM module imports, regardless of the surrounding module format.
Check the console for any detailed error messages or warnings provided by Splittable or Closure Compiler. Ensure source paths are correct and all dependencies (like Java) are properly set up. Enable `warnings: true` in options for more verbose output.
Verify your Java installation and ensure it's correctly configured in your system's PATH. If `splittable` was globally installed, try reinstalling it. Check for any environment variables that `splittable` might use to locate the Closure Compiler JAR.
Include a Promise polyfill in your HTML before loading Splittable's `_base.js` bundle. A common choice is PJs or a polyfill from `core-js`.
Double-check that `System.baseURL` is correctly set to the root directory where your Splittable bundles (including `_base.js`) are deployed. Verify the exact `module/path` string matches an entry module configured during bundling.