Registry / testing / react-app-rewire-webpack-bundle-analyzer

react-app-rewire-webpack-bundle-analyzer

JSON →
library1.1.0jsnpmunverified

A utility to integrate webpack-bundle-analyzer into Create React App configurations that use react-app-rewired (or react-scripts v1/v2). Version 1.1.0 (latest stable, updated in 2019) provides a simple wrapper that injects the BundleAnalyzerPlugin into the webpack config generated by CRA, with optional configuration passed directly to the plugin. It supports conditional activation based on environment (e.g., production only). Compared to alternatives like customize-cra or CRACO, this package is minimal and focused solely on bundle analysis. Note that it is not actively maintained and may not work with newer versions of CRA or webpack.

npm install react-app-rewire-webpack-bundle-analyzer
INSTALL
IMPORT
SIG · REACT-APP-REWIRE-W
R
react-app-rewire-webpack-bundle-analyzer
testingjavascriptv1.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default export
const rewireWebpackBundleAnalyzer = require('react-app-rewire-webpack-bundle-analyzer')
import rewireWebpackBundleAnalyzer from 'react-app-rewire-webpack-bundle-analyzer'
Package uses CommonJS; default export is a function. ESM import may fail in Node environments.
default export (named import)
export default rewireWebpackBundleAnalyzer;
export { rewireWebpackBundleAnalyzer };
The package exports a single function as default. Named export will be undefined.
TypeScript type import
// No types provided; use @ts-ignore or declare module
import type { RewireWebpackBundleAnalyzerOptions } from 'react-app-rewire-webpack-bundle-analyzer'
Package does not include TypeScript declarations. Type imports will error.
CommonJS require in ES module scope
import rewireWebpackBundleAnalyzer from 'react-app-rewire-webpack-bundle-analyzer'
const rewireWebpackBundleAnalyzer = require('react-app-rewire-webpack-bundle-analyzer')
If your project is configured as 'type': 'module', require() syntax will throw ERR_REQUIRE_ESM.

Configures webpack-bundle-analyzer in a react-app-rewired config-overrides.js to generate a static HTML report during production build.

const rewireWebpackBundleAnalyzer = require('react-app-rewire-webpack-bundle-analyzer'); module.exports = function override(config, env) { if (env === 'production') { config = rewireWebpackBundleAnalyzer(config, env, { analyzerMode: 'static', reportFilename: 'report.html' }); } return config; }; // Then run: react-app-rewired build
Debug
Known issues
breakingPackage is incompatible with react-scripts >= 3.0.0 due to changes in webpack configuration structure.
fix
Switch to CRACO or customize-cra with webpack-bundle-analyzer plugin directly.
affects: >1.1.0
gotchaThe analyzerMode option defaults to 'server' (opens browser) if not specified; may cause build hangs in CI.
fix
Always pass { analyzerMode: 'static', reportFilename: 'report.html' } for CI builds.
affects: <=1.1.0
deprecatedreact-app-rewired is effectively deprecated; consider migrating to CRACO (create-react-app-config-override).
fix
Replace react-app-rewired with @craco/craco and use craco-bundle-analyzer plugin.
affects: *
gotchaPackage does not support options validation; typos in options object pass silently with no effect.
fix
Double-check option spelling against webpack-bundle-analyzer docs.
affects: >=1.0.0
breakingRequires webpack-bundle-analyzer ^3.0.0; may conflict with newer versions.
fix
Pin webpack-bundle-analyzer to ~3.0.0 in package.json.
affects: >3.0.0
Errors
Common errors & fixes
Cannot find module 'react-app-rewire-webpack-bundle-analyzer'
Package not installed or not in node_modules.
fix
npm install --save-dev react-app-rewire-webpack-bundle-analyzer
TypeError: rewireWebpackBundleAnalyzer is not a function
Import used incorrect syntax (e.g., destructured import from default export).
fix
Use `const rewireWebpackBundleAnalyzer = require('react-app-rewire-webpack-bundle-analyzer')`
Error: Cannot read property 'userConfig' of undefined
react-app-rewired not installed or config-overrides.js not configured.
fix
Install react-app-rewired and ensure config-overrides.js exists in project root.
Error: webpack.optimize.OccurrenceOrderPlugin is not a constructor
Using webpack 4+ with older react-scripts (v1).
fix
Upgrade to react-scripts >= 2.0.0 or use react-app-rewired with compatibility layers.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
webpack-bundle-analyzerrequiredPeer dependency; the library wraps this plugin.
react-app-rewiredrequiredRequires react-app-rewired to be installed to override CRA config.
Agent activity
8 hits · last 30 days
node
8
Resources
react-app-rewire-webpack-bundle-analyzer — npm install react-app-rewire-webpack-bundle-analyzer · libregistry