kentcdodds / babel-plugin-macros

🎣 Allows you to build simple compile-time libraries
https://npm.im/babel-plugin-macros
MIT License
2.62k stars 135 forks source link

refactor: replace cosmiconfig with lilconfig #183

Open TrySound opened 2 years ago

TrySound commented 2 years ago

What:

cosmiconfig is a massive package which recently got a small alternative without dependencies lilconfig.

https://github.com/antonk52/lilconfig

https://packagephobia.com/result?p=cosmiconfig https://packagephobia.com/result?p=lilconfig

Though still a big part of cosmiconfig is yaml package. https://packagephobia.com/result?p=yaml

This package is important piece of relay and emotion. Would be good to make it as small as possible.

Why:

Node modules are bloated with large dependencies. I'm trying to help with this.

How:

Just switch to alternative.

Checklist:

TrySound commented 2 years ago

cc @kentcdodds

kentcdodds commented 2 years ago

Thanks for this! Is this a breaking change?

TrySound commented 2 years ago

Shouldn't be. lilconfig is mostly compatible. Yaml loaders are covered. Not sure why tests are failing. Looks like something unrelated to change.

kentcdodds commented 2 years ago

Bummer, looks like this project is using old versions of deps and something broke. I'm afraid I don't have any time to get things updated in this project and get things fixed so we can get this merged :(

TrySound commented 2 years ago

If you want I can take care of this on weekend.

conartist6 commented 2 years ago

It looks nonbreaking since it still requires yaml and defines a yaml loader. I really wouldn't mind seeing yaml config support dropped.

Would it work to just have yaml as an optional peer dependency?

kentcdodds commented 2 years ago

Whatever you two want to do. I don't use babel anymore.

TrySound commented 2 years ago

I don't personally use macros support but care about node_modules size so it's enough motivation. Will look tomorrow.

conartist6 commented 2 years ago

From what you shared just changing to lilconfig and yaml would save ~275kb in node_modules (751 -> 466KB of deps for config loading). It's a moderate win, but not nearly as big as also eliminating the useless yaml dep, at which point we'd be down to 27kb of config loading which finally sounds like a number on the correct order of magnitude.

TrySound commented 2 years ago

I fixed build here. Though not sure as ci run need to be approved. https://github.com/kentcdodds/babel-plugin-macros/pull/184

conartist6 commented 2 years ago

You'll also need to change https://github.com/kentcdodds/babel-plugin-macros/blob/d613985d297a73aeb3d7c8fad18a4944416b0bed/src/__tests__/index.js#L10-L18

What the heck is that for I wonder!?