SukkaW / nolyfill

Speed up your package installation process, reduce your disk usage, and extend the lifespan of your precious SSD.
MIT License
1.09k stars 15 forks source link

[Feature Request] `mkdirp` #59

Open wojtekmaj opened 7 months ago

wojtekmaj commented 7 months ago

In Node.js v10.12.0, recursive option was added to fs.mkdir and fs.mkdirSync. This option allows you to create a directory and all its parent directories if they do not exist.

mkdirp is still WIDELY used, for no apparent reason.

Each copy takes 104 kB.

SukkaW commented 7 months ago

In Node.js v10.12.0, recursive option was added to fs.mkdir and fs.mkdirSync. This option allows you to create a directory and all its parent directories if they do not exist.

mkdirp is still WIDELY used, for no apparent reason.

Each copy takes 104 kB.

The mkdirp is already implemented in a way that the native fs.mkdir and fs.mkdirSync API is always preferred.

On the other hand, the mkdirp package is now primarily used as a polyfill for Node.js version below 10.12, or as a cross-platform CLI (since cp is not available on Windows, you can't put cp in npm scripts).

wojtekmaj commented 7 months ago

When added as a dependency to a certain package though, it's unlikely (impossible?) for it to be used as a CLI though.

It's great that native APIs are preferred when possible. Still, 104 kB seems... excessive?

SukkaW commented 7 months ago

When added as a dependency to a certain package though, it's unlikely (impossible?) for it to be used as a CLI though.

It's great that native APIs are preferred when possible. Still, 104 kB seems... excessive?

But nolyfill CLI will always overwrite every copy of mkdirp, which could also break the intended CLI usage.

Besides, the main problem is that the mkdirp is a dual ESM/CJS package, which doubles the original size:

https://www.npmjs.com/package/mkdirp?activeTab=code

image