Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use 'lib' vs 'src' directory names in JavaScript? Which is 'standard'? [closed]

There are many popular JavaScript libraries and applications on GitHub and some put their raw source code in a /src directory, and others in a /lib directory.

I'm leaning towards the developers having done this depending on which languages they were taught growing up. So I see a lot of Java developers use /lib (who also normally end up putting their packaged JS into a /bin directory). Meanwhile I often observe that those who use /src output their packaged JS into a /dist folder instead.

What is considered the standard pattern for JavaScript, src or lib. Maybe there isn't a right or wrong answer at all.

like image 489
simbolo Avatar asked Jul 17 '16 21:07

simbolo


People also ask

What is lib and SRC?

/lib or /vendor - suggested putting your libraries which is not required for compilation. /src - for your code source.

What is lib directory used for?

lib is short for library which is often used for common files, utility classes, imported dependencies, or 'back in the days' also for dlls for (desktop) applications. It's in general a 'library' of supporting code for the core application.

Should lib be inside SRC?

lib & src. The difference in using lib vs src should be: lib if you can use node's require() directly. src if you can not, or the file must otherwise be manipulated before use.

What does the lib directory contain?

The /lib directory contains kernel modules and those shared library images (the C programming code library) needed to boot the system and run the commands in the root filesystem, ie. by binaries in /bin and /sbin. Libraries are readily identifiable through their filename extension of *. so.


2 Answers

Interesting question, but it seems to me that some developers just take it by their own worldview.

It also depends on the project:

Some projects are built with smaller components, which are just little pieces of the main functionality: lib.

lib/independent-pieces.js

Other projects are monolithic, the components depend on each other: src.

src/this-is-all-for-this-project-and-depend-on-each-other.js

For third-party libraries, it's common to use vendor.

vendor/bootstrap/ vendor/d3/ 
like image 137
webdeb Avatar answered Oct 01 '22 03:10

webdeb


  • /node_modules - for 3rd party libraries.
  • /lib or /vendor- suggested putting your libraries which is not required for compilation.
  • /src - for your code source
like image 40
Alex Filatov Avatar answered Oct 01 '22 03:10

Alex Filatov