Registry / devops / splittable

splittable

JSON →
library4.0.0jsnpmunverified

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 splittable
INSTALL
IMPORT
SIG · SPLITTABLE
S
splittable
devopsjavascriptv4.0.0
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.

splittable
const splittable = require('splittable');
import splittable from 'splittable';
Splittable is a CommonJS module. Direct ES module `import` syntax is not supported for the bundler itself. The `System.import` described in the README is for loading *output bundles*, not the `splittable` library.

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.'); });
splittable --version
Debug
Known issues
breakingSplittable relies on Java for the Google Closure Compiler. If Java is not installed or correctly configured in the system's PATH, Splittable will fail to run.
fix
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.
affects: >=1.0.0
gotchaWhen using Babel with Splittable, it is highly recommended to disable ES6 module transpilation (e.g., `modules: false` in `babel-preset-es2015` or similar presets). Splittable performs its own ES6 module compilation at a later stage, and pre-transpiling modules can lead to "very poor" (inefficient or bloated) generated code.
fix
Configure your Babel presets to explicitly set `modules: false` for ES6 module transformations. Example: `['es2015', { loose: true, modules: false }]`.
affects: >=1.0.0
gotchaThe `System.import` polyfill provided by Splittable's `_base.js` bundle requires a global `Promise` implementation. For older browsers that lack native Promise support, you must supply your own Promise polyfill (e.g., PJS or core-js).
fix
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.
affects: >=1.0.0
gotchaWhen loading bundles with `System.import`, the `System.baseURL` global variable must be explicitly set to the deployed directory of your Splittable bundles. Failing to do so will prevent the loader from finding and importing modules.
fix
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.
affects: >=1.0.0
gotchaSplittable supports CommonJS modules but with 'some caveats'. Specifically, cyclic dependencies are not supported and some Node.js modules may not be compatible due to environment differences. Also, `require("module-name")` must be used for NPM modules, even inside ES6 modules.
fix
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.
affects: >=1.0.0
Errors
Common errors & fixes
Compilation failed
A general error indicating issues during the bundling process, potentially due to incorrect configuration, source code errors, or underlying Closure Compiler failures.
fix
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.
java.lang.NoClassDefFoundError: com/google/javascript/jscomp/CommandLineRunner
This error indicates that the Java runtime cannot find the Closure Compiler's main class, typically because the Closure Compiler JAR is missing or not accessible to Splittable. This usually points to an issue with the Java installation or Splittable's internal dependency resolution for Closure Compiler.
fix
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.
ReferenceError: Promise is not defined
The `System.import` polyfill used by Splittable's generated bundles requires a global `Promise` object, which is missing in older JavaScript environments (e.g., IE11).
fix
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`.
Error: Failed to load module 'module/path': 404 Not Found
The `System.import` loader could not find the requested module bundle at the specified path. This often happens if `System.baseURL` is incorrect or the module path itself is misspelled.
fix
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.
Upgrade
Version history
4.0.0latest on npm
Audit
Dependencies
javarequiredSplittable uses Google Closure Compiler for advanced optimizations, which is a Java-based tool. Therefore, Java must be installed and accessible in the system's PATH.
Agent activity
2 hits · last 30 days
node
2
Resources