Registry / devops / bit-bundler-splitter

bit-bundler-splitter

JSON →
library7.0.0jsnpmunverified

bit-bundler-splitter is a plugin for the bit-bundler module bundler, designed to segment application code into smaller, optimized bundles, often referred to as 'bundle shards.' Its primary use case is to separate third-party vendor modules from application-specific code, leveraging browser caching for improved performance and reduced network traffic for returning visitors. The current stable version is 7.0.0, indicating continued development despite a non-fixed release cadence. Key differentiators include its flexible matching rules, powered by `roolio`, which allow granular control over module placement based on path, filename, or other properties. It automatically generates a `common` bundle to prevent module duplication across different shards and a `loader` bundle to manage the correct loading order of bundles in the browser. Furthermore, it supports building a sophisticated bundle tree for better dependency resolution and includes mechanisms for detecting circular references between generated bundles, contributing to a robust bundling strategy.

npm install bit-bundler-splitter
INSTALL
IMPORT
SIG · BIT-BUNDLER-SPLITT
B
bit-bundler-splitter
devopsjavascriptv7.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.

splitBundle
const splitBundle = require('bit-bundler-splitter');
import { splitBundle } from 'bit-bundler-splitter'; const { splitBundle } = require('bit-bundler-splitter');
The module exports a single function as its default. It is primarily a CommonJS module, so use `require` for direct access.
Plugin Reference (bit-bundler config)
['bit-bundler-splitter', { /* config */ }]
[require('bit-bundler-splitter'), { /* config */ }]
The most common and recommended usage is to provide the module name as a string within `bit-bundler`'s `bundler` plugin array. `bit-bundler` handles the internal resolution, which also future-proofs against potential changes in direct module export.

This quickstart demonstrates how to configure `bit-bundler-splitter` as a plugin within `bit-bundler` to split vendor and renderer-specific modules into separate output files, including basic error handling.

// First, install necessary packages: // npm install --save-dev bit-bundler bit-bundler-splitter bit-loader-babel const Bitbundler = require('bit-bundler'); const splitBundle = require('bit-bundler-splitter'); // Create dummy files for a runnable example: // src/main.js: console.log('Main application loaded'); require('./renderer/component'); // src/renderer/component.js: console.log('Renderer component loaded'); require('lodash'); // node_modules/lodash/lodash.js (or any other module) Bitbundler.bundle({ src: 'src/main.js', dest: 'dist/main.js' }, { loader: [ 'bit-loader-babel' // Example loader, often used for modern JS transpilation ], bundler: [ [splitBundle, [ { name: 'vendor', dest: 'dist/vendor.js', match: ['/bower_components/', '/node_modules/'] // Matches modules in these paths }, { name: 'renderer', dest: 'dist/renderer.js', match: '/src/renderer/' // Matches modules in the src/renderer path } ]] ] }).then(() => { console.log('Bundling complete! Check dist/main.js, dist/vendor.js, dist/renderer.js'); console.log('To run: cat dist/vendor.js dist/renderer.js dist/main.js | node'); }).catch(err => { console.error('Bundling failed:', err); });
Debug
Known issues
breakingThe `bit-bundler-splitter` plugin, as of v4.0.0, no longer accepts a `name` as the first argument directly. All configuration, including the bundle name, must now be provided via a single options object.
fix
Refactor plugin configurations from `['bit-bundler-splitter', 'my-name', {...}]` to `['bit-bundler-splitter', { name: 'my-name', ... }]`.
affects: >=4.0.0
breakingVersion 5.0.0 introduced a significant rewrite of `bit-bundler-splitter`, including a new bundle loader, support for building a bundle tree, and enhanced detection of circular references between bundles. This may require review and adjustments to existing bundle configurations due to potential architectural changes in how bundles are loaded and dependencies resolved.
fix
Carefully review the `v5.0.0` release notes and documentation to update your bundle configuration, paying close attention to bundle loading, tree construction, and how circular references are handled in your specific setup.
affects: >=5.0.0
gotchaA fix for 'not having the proper babel dependencies' was released in v5.0.1. If you are using `bit-loader-babel` alongside `bit-bundler-splitter`, older versions might lead to build failures due to missing Babel-related peer dependencies.
fix
Upgrade `bit-bundler-splitter` to `v5.0.1` or higher. Ensure all necessary Babel peer dependencies (e.g., `@babel/core`, `@babel/preset-env`) are explicitly installed in your project's `devDependencies`.
affects: <5.0.1
Errors
Common errors & fixes
Error: Plugin configuration for 'bit-bundler-splitter' is invalid. The 'name' property is missing or not an object.
Attempting to use the pre-v4 API by passing the bundle name as the first argument, or omitting the required options object entirely.
fix
Configure `bit-bundler-splitter` using an options object that includes a `name` property: `['bit-bundler-splitter', { name: 'vendor', dest: 'dist/vendor.js', match: [...] }]`.
TypeError: (0 , _bitBundlerSplitter.default) is not a function
Attempting to import `bit-bundler-splitter` using ES module syntax (`import`) or incorrectly destructuring its CommonJS `require` call, when the module exports a single function as its default.
fix
Use CommonJS `require` for the default export: `const splitBundle = require('bit-bundler-splitter');`
Error: Module build failed (from ../node_modules/bit-loader-babel/index.js): Error: Cannot find module '@babel/core'
Missing essential Babel-related peer dependencies when `bit-loader-babel` is utilized in conjunction with `bit-bundler-splitter` within your `bit-bundler` setup.
fix
Install the required Babel packages as dev dependencies: `npm install --save-dev @babel/core @babel/preset-env` and ensure `bit-bundler-splitter` is at least `v5.0.1`.
Upgrade
Version history
7.0.0latest on npm
Audit
Dependencies
bit-bundlerrequiredThis package is a plugin for bit-bundler and requires it to operate.
Agent activity
8 hits · last 30 days
node
6
OpenAI (training)
1
Resources
bit-bundler-splitter — npm install bit-bundler-splitter · libregistry