Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

About

Source code for browserify-resolutions

Resources

Stars

19 stars

Watchers

20 watching

Forks

Latest commit

 

History

51 Commits

Folders and files

Repository files navigation

#browserify-resolutions build status Bower resolutions for npm + Browserify... sort of.

A Browserify plugin that allows more explicit control of module deduping. It purges duplicate modules from the output bundle and prevents modules from loading several times.

Why?

A large dependency tree may include multiple versions of the same module, which may result in it being bundled multiple times, greatly increasing the bundle's size.

What about npm dedupe?

It can be sufficient, but is sometimes hamstrung as third party modules may be asking for incompatible versions of the same library.

What about peerDependencies?

Hopefully solves this problem in the future, but currently difficult to work with: npm/npm#6565

What about Browserify's own dedupe?

It currently only dedupes identical source files. Even if deduped, a library may be instantiated several times.

E.g., even if Angular is deduped and only bundled once, you may still see:

WARNING: Tried to load angular more than once.

How to use

Pass either an array of package names to dedupe or "*" to dedupe everything possible.

var resolutions = require('browserify-resolutions');
// Dedupe Angular
browserify(options)
  .plugin(resolutions, ['angular'])
  .bundle();
// Dedupe everything possible
browserify(options)
  .plugin(resolutions, '*')
  .bundle();

via Browserify CLI

browserify path-to-your-entry-file.js -p [ browserify-resolutions '*' ] -o path-to-your-destination.js

About

Source code for browserify-resolutions

Resources

Stars

19 stars

Watchers

20 watching

Forks

Releases

Packages

Used by

Contributors

Languages