Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is node-libs-browser and why is it being installed when I install babel-loader

I have just installed babel loader, to use babel with webpack.

It brings in 3 additional node dependencies, however only 2 of these I expected

from the babel loader package.json

"peerDependencies": {
  "babel-core": "*",
  "webpack": "*"
},

So why am I also getting node-libs-browser I don't know what it is, and don't want the extra module in my devDependencies

like image 291
svnm Avatar asked Jun 25 '15 04:06

svnm


People also ask

What is node libs browser?

node-libs-browser is a peer dependency of Webpack. As stated in the package page it provides certain Node libraries for browser usage. Obviously modules such as fs won't be available there but you can still use quite a few.

Why do we need babel-loader?

babel-loader exposes a loader-builder utility that allows users to add custom handling of Babel's configuration for each file that it processes.

How does a babel-loader work?

Babel is a compiler; it takes an ESNext program and produces an equivalent ES3+ compatible program. babel-loader does what ts-loader does for TypeScript; passes off files to the Babel compiler, and returns the result to be used in the bundle in-place of the original source program.


1 Answers

IMPORTANT! As pointed out by Patrik, Webpack can deal with it now so you don't need to install it separately. It has been moved as a direct dependency of Webpack.


OLD ANSWER

node-libs-browser is a peer dependency of Webpack. As stated in the package page it provides certain Node libraries for browser usage. Obviously modules such as fs won't be available there but you can still use quite a few.

It is recommended that you maintain the versions of peer dependencies like this yourself. In fact that's going to be the default starting from npm 3. For now they get installed automatically. Therefore it's a good idea to have them listed explicitly at devDependencies even if that might feel like some extra work at the moment.

like image 111
Juho Vepsäläinen Avatar answered Sep 26 '22 03:09

Juho Vepsäläinen