0

I'm confused on why the packages in the dev environment aren't needed in the production environment. For example the babel-plugin-lodash lets you do some transformations for free, but won't you still need them when your code is running in production?

$ npm i --save lodash
$ npm i --save-dev babel-plugin-lodash babel-cli babel-preset-es2015
stackjlei
  • 9,485
  • 18
  • 65
  • 113
  • Babel doesn't run client-side. It's used in the dev environment to *build* browser-friendly JavaScript for production out of your ES6/ES7/ES∞ code, so dev is appropriate. – ceejayoz Oct 27 '17 at 19:34
  • This might be helpful: https://stackoverflow.com/questions/18875674/whats-the-difference-between-dependencies-devdependencies-and-peerdependencies – Sumit Oct 27 '17 at 19:43
  • @ceejayoz so that means that the still in `--save-dev` is during the build process, regardless of the final bundle being used for development or production? And then the packages in `--save` will always be served as part of that bundle? I've always thought the dev environment refers to when you're developing code locally, not to a stage at which the code is being built to be served. – stackjlei Oct 28 '17 at 23:37
  • 1
    Building *for* production is a development process. – ceejayoz Oct 29 '17 at 00:18
  • @ceejayoz how does it work if you `yarn add` a package and your project doesn't install that package's devDependencies? Doesn't that mean that the package won't be able to be built to be used by your project? – stackjlei Nov 05 '17 at 01:22
  • `devDependencies` are what you need to develop that module. You don't need them to simply *use* that module. – ceejayoz Nov 05 '17 at 04:20
  • @ceejayoz say a package has a devDependency on babel and webpack to be built, how can you not need to them in order to use that package if that package needs them to be built? does it not have to be built in order to be used? – stackjlei Nov 05 '17 at 23:36
  • @ceejayoz If devDependencies aren't in the picture at all, how does a package that relies on webpack and babel to transcompile its es6 into es5 work within a project that requires the package but that project is only in es5? – stackjlei Nov 05 '17 at 23:50

0 Answers0