Does Create-React-App (or Webpack used by Create-React-App) at any stage (development, staging or production) optimise your node_modules? That is, if I had an import like this:
import _ from 'lodash'
and only use the map
function in my project. Would my build bundle for production have all of lodash or would it strip out all other functions and keep the ones that are being referenced in my code?
CRA use
UglifyJsPlugin
in the webpack.config.prod.js which supports dead code removal.But you should only import what you need for this to work: https://webpack.js.org/guides/tree-shaking/