Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pnpmfile-nolyfill: nolyfill your dependencies on install #100

Open
lishaduck opened this issue Sep 12, 2024 · 5 comments
Open

pnpmfile-nolyfill: nolyfill your dependencies on install #100

lishaduck opened this issue Sep 12, 2024 · 5 comments

Comments

@lishaduck
Copy link

lishaduck commented Sep 12, 2024

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:

  • Install by coping the .pnpmfile.cjs into your project.
  • Reinstall repository by executing pnpm i.
  • Poof! ✨ (notice all the noisy logging! 🎉)

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 SukkaW pinned this issue Sep 12, 2024
@SukkaW
Copy link
Owner

SukkaW commented Sep 12, 2024

@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
Copy link
Author

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

@wojtekmaj
Copy link

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

@lishaduck
Copy link
Author

lishaduck commented Sep 13, 2024

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
Copy link
Author

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

Footnotes

  1. Probably, gotta finish watching ViteConf 🙃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants