Coder Social home page Coder Social logo

lodash-webpack-bundle-size's Introduction

lodash-webpack-bundle-size

Simulating different approaches for code-splitting lodash.

In index.js, both lodash & lodash-es dependencies are used for simulating code-splitting with different webpack configurations.

webpack configurations

Four webpack configurations are used to see which config approach yields the best results. Each configuration is also accompanied by a webpack-bundle-analyzer-report which can be found in the dist-folder.

These are the 4 configurations:

  • non optimized
  • lodash babel plugin
  • lodash webpack plugin
  • combination of babel and webpack plugins

1. Non optimized

Only entry & output properties are used in non-optimized config.

2. Babel plugin

Only babel-plugin-lodash is used in this config with babel plugin.

3. webpack plugin

Only lodash-webpack-plugin is used in this config with webpack plugin.

4. Combination of Babel & webpack plugins

A combination of babel-plugin-lodash and lodash-webpack-plugin is used in this config with babel and webpack plugins.

Results

Config File Size
babel and webpack plugin dist/babel-webpack.js 1.96 KB
babel plugin dist/babel.js 21.90 KB
webpack plugin dist/webpack.js 71.50 KB
non optimized dist/non-optimized.js 79.60 KB

Warning

The configuration where both babel and webpack plugins are used, result in a staggering small bundle size. The reason why is because a lot of behind-the-scene features of lodash are removed by the lodash-webpack-plugin, which explains the big savings.

For example, lodash's get will not behave as expected if lodash-webpack-plugin is used.

Here's a full list of features that are disabled by lodash-webpack-plugin: github.com/lodash/lodash-webpack-plugin#feature-sets.

You can choose to opt-in to certain features like this:

new LodashModuleReplacementPlugin({
  collections: true,
  paths: true
});

lodash-webpack-bundle-size's People

Contributors

dependabot[bot] avatar mhxbe avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.