Why is this library so big?
joker-777 opened this issue · comments
You can get some reduction by loading only the core functionality, plus whichever optional components you want.
Minimal example:
const Rollbar = require('rollbar/src/browser/core');
const rollbar = Rollbar.init(config);
Example with all optional features included:
const Rollbar = require('rollbar/src/browser/core');
const telemeter = require('rollbar/src/telemetry');
const instrumenter = require('rollbar/src/browser/telemetry');
const polyfillJSON = require('rollbar/vendor/JSON-js/json3');
const wrapGlobals = require('rollbar/src/browser/wrapGlobals');
const scrub = require('rollbar/src/scrub');
const truncation = require('rollbar/src/truncation');
Rollbar.setComponents({
telemeter: telemeter,
instrumenter: instrumenter,
polyfillJSON: polyfillJSON,
wrapGlobals: wrapGlobals,
scrub: scrub,
truncation: truncation
});
const rollbar = Rollbar.init(config);
The following size estimates are based on a vanilla webpack 4 config, and measure the pre-zip minified size.
The minified size of the minimal package (browser/core only) is 49K.
Base telemeter - The previously always-on telemetry capture for Rollbar message logging.
require(rollbar/src/telemetry) (saves ~3K minified)
Browser telemetry - All browser telemetry capabilities: Console, network, click events, etc.
require(rollbar/src/browser/telemetry) (saves ~14K minified)
JSON polyfill - Some pre-2009 browsers require a polyfill for JSON.stringify and JSON.parse.
require(rollbar/vendor/JSON-js/json3) (saves ~7K minified)
Wrap globals - This is already disabled by default. Most people would benefit from not bundling.
require('rollbar/src/browser/wrapGlobals') (saves ~1K)
Scrub - By making parts of the payload optional, there may be no remaining need for scrubbing in specific configurations. Or the remaining payload isn’t considered sensitive by the user.
require('rollbar/src/scrub') (saves ~1K)
Truncation - Not likely needed when telemetry isn't present.
require('rollbar/src/truncation') (saves ~1.6K)