Registry / web-framework / redux-bundler

redux-bundler

JSON →
library29.1.0jsnpmunverified

Redux Bundler is a pragmatic state management library that facilitates building Redux stores by composing smaller, self-contained units of functionality called 'bundles.' Designed with Progressive Web Apps (PWAs) in mind, it emphasizes small bundle sizes, network resilience, and explicit state management, aiming to reduce the boilerplate often associated with traditional Redux setups. It formalizes an opinionated 'ducks pattern,' consolidating actions, reducers, and selectors for a specific feature into a single bundle file. The library provides a convention-over-configuration approach for managing side effects through 'reactors' and includes a lightweight, optional routing system. While it leverages and re-exports much of Redux's core functionality, it offers an alternative to Redux Toolkit, providing a distinct organizational structure and patterns. The current stable version is 29.1.0, with a rapid release cadence often including major version bumps even for non-breaking changes to ensure safety. It uniquely supports running entirely within a WebWorker and enables code-splitting and lazy-loading of Redux logic.

npm install redux-bundler
INSTALL
IMPORT
SIG · REDUX-BUNDLER
R
redux-bundler
web-frameworkjavascriptv29.1.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.

composeBundles
import { composeBundles } from 'redux-bundler'
const { composeBundles } = require('redux-bundler')
Primary utility for combining bundles into a store factory. ESM import is preferred in modern applications.
createSelector
import { createSelector } from 'redux-bundler'
import { createSelector } from 'reselect'
Redux-bundler re-exports `createSelector` from `reselect` internally, so import directly from `redux-bundler` to avoid redundant dependencies.
createStore
import { createStore } from 'redux-bundler'
import { createStore } from 'redux'
While `createStore` is a core Redux function, `redux-bundler` re-exports it. Importing from `redux-bundler` ensures consistency and leverages its bundled Redux version.

This example demonstrates defining a simple user bundle with a reducer, selectors, and action creators. It then composes this bundle to create a Redux store, dispatches actions, and shows how to select state and subscribe to changes.

import { composeBundles } from 'redux-bundler'; const userBundle = { name: 'user', getReducer: () => { const initialState = { name: 'Guest', isAuthenticated: false, loading: false }; return (state = initialState, action) => { switch (action.type) { case 'USER_LOGIN_START': return { ...state, loading: true }; case 'USER_LOGIN_SUCCESS': return { ...state, name: action.payload.name, isAuthenticated: true, loading: false }; case 'USER_LOGOUT': return { ...initialState }; default: return state; } }; }, selectUserName: (state) => state.user.name, selectIsAuthenticated: (state) => state.user.isAuthenticated, selectUserLoading: (state) => state.user.loading, doLogin: (payload) => ({ dispatch, store }) => { dispatch({ type: 'USER_LOGIN_START' }); // Simulate API call setTimeout(() => { const userName = payload.username || 'Test User'; dispatch({ type: 'USER_LOGIN_SUCCESS', payload: { name: userName } }); console.log(`User '${store.selectUserName()}' logged in.`); }, 500); }, doLogout: () => ({ dispatch }) => { dispatch({ type: 'USER_LOGOUT' }); console.log('User logged out.'); }, }; const getStore = composeBundles(userBundle); const store = getStore(); // Subscribe to changes (optional, but common in frameworks like React) store.subscribe(() => { console.log('Current user name:', store.selectUserName()); console.log('Is authenticated:', store.selectIsAuthenticated()); }); // Dispatch actions store.doLogin({ username: 'Alice' }); setTimeout(() => { store.doLogout(); }, 1000);
Debug
Known issues
breakingRedux-bundler frequently releases new major versions (e.g., v29, v28, v27, v25, v24, v23) even for changes deemed 'unlikely to be breaking' internally. Always consult the changelog before upgrading to a new major version.
fix
Thoroughly review the `CHANGELOG.md` file or the documentation site (reduxbundler.com) for any specific migration steps required for your version upgrade. Pay close attention to changes in bundle configuration options or internal mechanics.
affects: >=23.0.0
gotchaRedux-bundler bundles its Redux and Reselect dependencies internally to ensure version compatibility. Users should avoid installing `redux` or `reselect` directly in their project's `package.json` to prevent duplicate instances or version conflicts.
fix
Remove `redux` and `reselect` from your project's `package.json` if they are direct dependencies. Import Redux utilities (like `createStore`, `combineReducers`) and `createSelector` directly from `redux-bundler`.
affects: >=16.0.0
gotchaFor production builds, ensure `NODE_ENV` is set to `"production"`. Redux-bundler includes debug blocks from the underlying Redux library, which can increase bundle size if not stripped out during minification.
fix
Configure your build tools (e.g., Webpack, Rollup) to set `process.env.NODE_ENV = 'production'` when building for production environments. This will enable dead-code elimination for debug-only code.
affects: >=16.0.0
breakingThe `createCacheBundle` API changed in v25.0.0, now requiring an options object as an argument instead of just a cache function. This change introduced support for an `enabled` option for Node.js environments and a `logger` function.
fix
Update calls to `createCacheBundle` to pass an options object, for example: `createCacheBundle({ cacheFn: yourCacheFunction, enabled: true })`.
affects: >=25.0.0
gotchaOlder versions (pre-28.0.1) could encounter 'ILLEGAL invocation' errors when using `requestIdleCallback` or `requestAnimationFrame` due to bundler optimizations removing context.
fix
Upgrade to `redux-bundler` version 28.0.1 or higher. If upgrading is not immediately possible, consider explicitly binding these functions to `window` or `globalThis` where they are used.
affects: <28.0.1
Errors
Common errors & fixes
A state mutation was detected between dispatches
A reducer in one of your bundles is directly modifying the state object instead of returning a new one.
fix
Ensure all reducers adhere to immutability principles. Always return new state objects or arrays using spread syntax (`{...state, ...}`, `[...arr, item]`) or immutable utility libraries.
TypeError: Cannot read properties of undefined (reading 'someProperty') in selector 'selectSomeData'
A selector is attempting to access a property on a part of the state tree that is undefined, often because the expected state shape hasn't been initialized or an upstream bundle isn't providing data.
fix
Check the `getReducer` of the relevant bundle to ensure it defines an appropriate `initialState` with all expected nested properties. Also, verify that any bundles providing data for this selector are correctly integrated.
Error: Action 'SOME_ACTION' dispatched but no reducer handled it
An action was dispatched, but no reducer within any of the composed bundles has a `case` statement matching its `type` property.
fix
Verify the action `type` string exactly matches a `case` in one of your reducers. Ensure the bundle containing the intended reducer is included in the `composeBundles` call.
Upgrade
Version history
29.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
30 hits · last 30 days
node
26
OpenAI (training)
1
Resources
redux-bundler — npm install redux-bundler · libregistry