SukkaW / nolyfill

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

`pnpmfile-nolyfill`: nolyfill your dependencies on install #100

Open lishaduck opened 2 months ago

lishaduck commented 2 months ago

Hello! I wanted to use nolyfill in a pnpm project, so I went ahead and wrote a pnpmfile for nolyfilling pnpm dependencies. Plenty of credit (and thanks) to @wojtekmaj for yarn-plugin-nolyfill (and the phrasing for this issue 😜), on which I based my initial implementation (though pnpm's primitives are very different, so the 10 lines that matter ended up pretty different).

How to use:

You're more than welcome to try it out and let me know what you think.

The source code is at github:lishaduck/pnpmfile-nolyfill.


Yay, I got issue 100 🥳 🙃

SukkaW commented 2 months ago

@lishaduck Ideally this should be a pacakge! And people would do:

// pnpmfile.cjs
const { withNolyfill } = require('pnpmfile-nolyfill');

module.exports = withNolyfill({
  hooks: {},
});

...instead of copy-pasting!

lishaduck commented 2 months ago

I thought about that, but how would you install it if its part of the resolver?

wojtekmaj commented 2 months ago

I believe you should be able to use pre-existing modules while you're re-installing the repo?

lishaduck commented 2 months ago

I believe you should be able to use pre-existing modules while you're re-installing the repo?

Yes, you could, but on the initial install, it'd crash. In an ideal world, pnpm would just support inline script metadata (from python), but as it stands, you can't (a) run a clean install (i.e., in ci), or (b) reinstall from scratch (think the bootstrap problem).

I guess one option would be requiring to install it as a global dependency first, then as a local one, but that prevents SemVer majors 🤷‍♂️

lishaduck commented 4 weeks ago

I just found this really old comment. I'm going to try it tomorrow,[^1] and if it works, I'll publish pnpmfile-nolyfill.

[^1]: Probably, gotta finish watching ViteConf 🙃