title: LodashModuleReplacementPlugin
body: <p>I am try to use LodashModuleReplacementPlugin to reduce bundle size. I have followed the instruction of the <a href="https://github.com/lodash/lodash-webpack-plugin" rel="nofollow noreferrer">Documentation</a>. But seems like the main.bundle.js is still including /node_modules/lodash.js.</p>
  <p>Here are the corresponding files:</p>
  <p><strong>webpack.config.js</strong></p>
  <pre><code>...
  var LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
  ...
  
  const configuration = {
    module: {
      rules: [
        {
          test: /\.js$/,
          // https://stackoverflow.com/questions/50173228/how-to-include-node-module-for-babel-using-webpack
          // fast-xml-parser was still es6 and needed to be included in babel-loader (Unexpected token: name (match))
          exclude: /node_modules\/((?!(fast-xml-parser)\/|(react-toastr)|(table)|(webpack-bundle-anaylzer)\/)).*/,
          use: [
            {
              loader: &quot;babel-loader&quot;,
              options: {
                'plugins': ['lodash'],
              }
            }
          ]
        },
  ...
  plugins: [
      new LodashModuleReplacementPlugin,
  ...
  ]}
  </code></pre>
  <p><strong>package.json</strong></p>
  <pre><code> &quot;dependencies&quot;: {
      &quot;@stripe/react-stripe-js&quot;: &quot;^1.1.2&quot;,
      &quot;@stripe/stripe-js&quot;: &quot;^1.9.0&quot;,
      &quot;add&quot;: &quot;^2.0.6&quot;,
      &quot;autoprefixer&quot;: &quot;^7.2.6&quot;,
      &quot;babel-plugin-transform-function-bind&quot;: &quot;^6.22.0&quot;,
      &quot;babel-preset-latest&quot;: &quot;^6.22.0&quot;,
      &quot;babel-preset-react&quot;: &quot;^6.22.0&quot;,
      &quot;babel-preset-stage-2&quot;: &quot;^6.22.0&quot;,
      &quot;babel-register&quot;: &quot;^6.22.0&quot;,
      &quot;babel-runtime&quot;: &quot;^6.9.2&quot;,
      &quot;body-parser&quot;: &quot;^1.19.0&quot;,
      &quot;bootstrap-sass&quot;: &quot;^3.3.7&quot;,
      &quot;braintree-web&quot;: &quot;3.5.0&quot;,
      &quot;clean-webpack-plugin&quot;: &quot;^0.1.19&quot;,
      &quot;compressorjs&quot;: &quot;1.0.6&quot;,
      &quot;connect-redis&quot;: &quot;^3.3.3&quot;,
      &quot;css-loader&quot;: &quot;^4.2.2&quot;,
      &quot;es6-promise-pool&quot;: &quot;^2.4.4&quot;,
      &quot;express&quot;: &quot;^4.16.2&quot;,
      &quot;express-device&quot;: &quot;^0.4.2&quot;,
      &quot;express-session&quot;: &quot;^1.15.6&quot;,
      &quot;extract-css-chunks-webpack-plugin&quot;: &quot;^4.7.5&quot;,
      &quot;hoist-non-react-statics&quot;: &quot;^2.5.0&quot;,
      &quot;ie-version&quot;: &quot;^0.1.0&quot;,
      &quot;img-loader&quot;: &quot;^3.0.1&quot;,
      &quot;immer&quot;: &quot;^6.0.9&quot;,
      &quot;incstr&quot;: &quot;^1.2.3&quot;,
      &quot;json-loader&quot;: &quot;^0.5.4&quot;,
      &quot;localforage&quot;: &quot;^1.5.0&quot;,
      &quot;lodash&quot;: &quot;^4.14.0&quot;,
      &quot;lodash-cli&quot;: &quot;^4.17.5&quot;,
      &quot;moment&quot;: &quot;2.14.1&quot;,
      &quot;moment-timezone&quot;: &quot;0.5.4&quot;,
      &quot;node-polyglot&quot;: &quot;^2.0.0&quot;,
      &quot;node-sass&quot;: &quot;^4.9.0&quot;,
      &quot;nodemon&quot;: &quot;^1.17.1&quot;,
      &quot;npm-run-all&quot;: &quot;^4.1.2&quot;,
      &quot;path&quot;: &quot;^0.12.7&quot;,
      &quot;postcss-import&quot;: &quot;^12.0.0&quot;,
      &quot;postcss-loader&quot;: &quot;^3.0.0&quot;,
      &quot;postcss-url&quot;: &quot;^9.0.0&quot;,
      &quot;prompt&quot;: &quot;^1.0.0&quot;,
      &quot;prop-types&quot;: &quot;^15.6.0&quot;,
      &quot;raw-loader&quot;: &quot;^3.1.0&quot;,
      &quot;react&quot;: &quot;^16.0.0&quot;,
      &quot;react-bootstrap&quot;: &quot;1.0.0-beta.3&quot;,
      &quot;react-click-outside&quot;: &quot;^2.1.0&quot;,
      &quot;react-day-picker&quot;: &quot;7.4.0&quot;,
      &quot;react-dom&quot;: &quot;^16.0.0&quot;,
      &quot;react-ga&quot;: &quot;^2.5.5-0&quot;,
      &quot;react-helmet&quot;: &quot;^5.2.0&quot;,
      &quot;react-hot-loader&quot;: &quot;^3.1.3&quot;,
      &quot;react-image-gallery&quot;: &quot;^0.8.7&quot;,
      &quot;react-inlinesvg&quot;: &quot;^0.7.5&quot;,
      &quot;react-input-range&quot;: &quot;^0.9.3&quot;,
      &quot;react-modal&quot;: &quot;^1.6.5&quot;,
      &quot;react-overlays&quot;: &quot;^1.1.1&quot;,
      &quot;react-redux&quot;: &quot;^5.1.1&quot;,
      &quot;react-render&quot;: &quot;^1.1.0&quot;,
      &quot;react-router&quot;: &quot;4.3.1&quot;,
      &quot;react-router-bootstrap&quot;: &quot;^0.19.3&quot;,
      &quot;react-router-config&quot;: &quot;^1.0.0-beta.4&quot;,
      &quot;react-router-dom&quot;: &quot;4.3.1&quot;,
      &quot;react-slick&quot;: &quot;^0.23.1&quot;,
      &quot;react-toastr&quot;: &quot;2.9.5&quot;,
      &quot;react-waypoint&quot;: &quot;^8.0.0&quot;,
      &quot;redis&quot;: &quot;^2.8.0&quot;,
      &quot;redux&quot;: &quot;^3.7.2&quot;,
      &quot;redux-thunk&quot;: &quot;^1.0.2&quot;,
      &quot;resolve-url-loader&quot;: &quot;^2.3.2&quot;,
      &quot;sass-loader&quot;: &quot;^6.0.2&quot;,
      &quot;serialize-javascript&quot;: &quot;^1.4.0&quot;,
      &quot;skygear&quot;: &quot;1.4.0&quot;,
      &quot;slick-carousel&quot;: &quot;^1.6.0&quot;,
      &quot;store&quot;: &quot;^1.3.17&quot;,
      &quot;stripe&quot;: &quot;^8.89.0&quot;,
      &quot;style-loader&quot;: &quot;^1.2.1&quot;,
      &quot;superagent&quot;: &quot;^1.6.1&quot;,
      &quot;sync-exec&quot;: &quot;^0.6.2&quot;,
      &quot;toastr&quot;: &quot;^2.1.4&quot;,
      &quot;transform-class-properties&quot;: &quot;^0.1.0&quot;,
      &quot;uglifyjs-webpack-plugin&quot;: &quot;^1.2.3&quot;,
      &quot;universal-cookie&quot;: &quot;^2.1.2&quot;,
      &quot;webpack-cli&quot;: &quot;^3.3.12&quot;,
      &quot;webpack-merge&quot;: &quot;^4.1.2&quot;,
      &quot;webpack-node-externals&quot;: &quot;^1.6.0&quot;
    },
    &quot;devDependencies&quot;: {
      &quot;@babel/preset-env&quot;: &quot;^7.11.0&quot;,
      &quot;babel-cli&quot;: &quot;^6.14.0&quot;,
      &quot;babel-core&quot;: &quot;^6.26.3&quot;,
      &quot;babel-eslint&quot;: &quot;^6.1.2&quot;,
      &quot;babel-loader&quot;: &quot;^7.1.5&quot;,
      &quot;babel-plugin-lodash&quot;: &quot;^3.3.4&quot;,
      &quot;babel-plugin-transform-runtime&quot;: &quot;^6.23.0&quot;,
      &quot;babel-preset-env&quot;: &quot;^1.7.0&quot;,
      &quot;cookie-storage&quot;: &quot;^1.0.4&quot;,
      &quot;eslint&quot;: &quot;^3.10.0&quot;,
      &quot;eslint-plugin-react&quot;: &quot;^5.2.2&quot;,
      &quot;expect&quot;: &quot;^1.20.2&quot;,
      &quot;file-loader&quot;: &quot;^1.1.11&quot;,
      &quot;localStorage&quot;: &quot;^1.0.3&quot;,
      &quot;lodash-webpack-plugin&quot;: &quot;^0.11.5&quot;,
      &quot;mocha&quot;: &quot;^2.5.3&quot;,
      &quot;url-loader&quot;: &quot;^4.1.0&quot;,
      &quot;webpack&quot;: &quot;^4.44.1&quot;,
      &quot;webpack-bundle-analyzer&quot;: &quot;^3.8.0&quot;,
      &quot;webpack-dev-server&quot;: &quot;^3.1.4&quot;,
      &quot;webpack-hot-middleware&quot;: &quot;^2.17.1&quot;
    }
  </code></pre>
  <p><strong>.babelrc</strong></p>
  <pre><code>{
    &quot;presets&quot;:
    [
      &quot;react&quot;,
      [&quot;latest&quot;, { modules: false }],
      &quot;stage-2&quot;
    ],
  
    &quot;plugins&quot;:
    [
      &quot;react-hot-loader/babel&quot;,
      &quot;transform-function-bind&quot;,
      &quot;lodash&quot;
    ]
  }
  </code></pre>
  <p><strong>Webpack-Bundle-Analyzer Graph</strong> - <a href="https://i.stack.imgur.com/KdJJY.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/KdJJY.jpg</a></p>