News for hackers. Stuff that matters.
Re:We check our node_modules folder into source control by ilumanty on Saturday December 11, 2021 @07:33PM (#29525780)
Yarn offers "Plug'n'play" mode since v2, which basically promotes what the author says. It takes the idea further: dependencies are stored as zip archives instead of thousands of small files, which reduces the "git noise" and actually makes this viable as a performant workflow.

https://yarnpkg.com/features/pnp

Re:We check our node_modules folder into source control by rarkins on Sunday December 12, 2021 @01:52AM (#29527684)
Yarn’s offline support is not directly tied to PNP. Yarn v1’s support for “offline” installs was a day one requirement, and as I understand it one of the primary drivers for Facebook engineers (at the time) to drive the creation of Yarn.

If offline installs is what you want, I don’t see any advantage of node_modules compared to this feature - only disadvantages (size, noise, and cross-platform incompatibilities).

Re:We check our node_modules folder into source control by Jarred on Saturday December 11, 2021 @11:21PM (#29527114)
Unfortunately, reading files from .zip can be considerably slower than the filesystem.

On an Ubuntu x86_64 machine with an SSD, require("react") with Yarn PnP ends up 4x slower than when installed from npm (Node 14.17.6).

Re:We check our node_modules folder into source control by DecoPerson on Sunday December 12, 2021 @03:20AM (#29527987)
I might be misremembering but at runtime, the Node process loads .pnp.js, which is a kind of monolithic “compiled” modules file containing all the modules installed. No reading of the .zip files occurs at runtime. (Again, I might be misremembering or have misunderstood. Please confirm/deny this if you know.)
Re:We check our node_modules folder into source control by matharmin on Sunday December 12, 2021 @09:10AM (#29529737)
The pnp.js file has a list of modules, not the modules themselves. The modules are still read from zip files at runtime.

Yarn doesn't do any kind of compilation itself - that would be done by build tools like webpack.

Re:We check our node_modules folder into source control by charrondev on Sunday December 12, 2021 @01:42PM (#29532300)
I’d be curious how “read file from a zip that I know the exact path to” performs compared to “recursively walk the node_modules directory and dynamically lookup the location of the file”.
Re:We check our node_modules folder into source control by maxpert on Saturday December 11, 2021 @07:40PM (#29525838)
Exactly reading article I for a second felt like author was either not fully aware of tooling, or doesn't care about the noise it will cause (potentially complex conflicts) checking node_modules will cause.
Re:We check our node_modules folder into source control by ronenlh on Sunday December 12, 2021 @12:48AM (#29527459)
Specifically, it’s the zero-installs philosophy. It’s linked from the url you shared.

https://yarnpkg.com/features/zero-installs

It’s also compares this with checking node_modules into git

Re:We check our node_modules folder into source control by brodo on Sunday December 12, 2021 @02:11AM (#29527735)
Also if you use the yarn deployment plugin (forgot the name), it will create a deployment folder for you that does not contain dev dependencies. This way we found a package that was installed as a dev dependency but in reality was a regular runtime dependency.
Re:We check our node_modules folder into source control by wruza on Sunday December 12, 2021 @03:11AM (#29527955)
Yarn pnp was in a poor state tooling-wise last time I checked it a year or so ago. Too many tools depend on ./node_modules/ (or actually an entire module.paths thing) to exist on a filesystem. Was it resolved somehow?
Re:We check our node_modules folder into source control by hasmolo on Sunday December 12, 2021 @10:14AM (#29530228)
by and large it has been solved with editor extensions and pnp plugins for various tools, i've used yarn 2/3 at enterprise scale for a few years now and am happy with it
Re:We check our node_modules folder into source control by mkranjec on Sunday December 12, 2021 @09:27AM (#29529867)
Wanted to suggest the same thing. Used Yarn 2 PnP with zero installs in the past company and it worked great. Whenever I switched to projects not using it install seemed to take ages. Used that only on backend, YMMV.
Re:We check our node_modules folder into source control by hasmolo on Sunday December 12, 2021 @10:15AM (#29530235)
and yarn 3 will even allow for node_module linker usage instead of cjs require hook overload
Re:We check our node_modules folder into source control by Bellend on Saturday December 11, 2021 @07:41PM (#29525855)
It's awesome apart from the vast majority don't use yarn.