babel-plugin-macros icon indicating copy to clipboard operation
babel-plugin-macros copied to clipboard

refactor: replace cosmiconfig with lilconfig

Open TrySound opened this issue 3 years ago • 11 comments

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:

  • [ ] Documentation
  • [x] Tests
  • [x] Ready to be merged

TrySound avatar Jan 07 '22 13:01 TrySound

cc @kentcdodds

TrySound avatar Jan 07 '22 13:01 TrySound

Thanks for this! Is this a breaking change?

kentcdodds avatar Jan 07 '22 22:01 kentcdodds

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

TrySound avatar Jan 07 '22 22:01 TrySound

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 :(

kentcdodds avatar Jan 07 '22 22:01 kentcdodds

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

TrySound avatar Jan 07 '22 22:01 TrySound

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?

conartist6 avatar Jan 07 '22 22:01 conartist6

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

kentcdodds avatar Jan 07 '22 22:01 kentcdodds

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

TrySound avatar Jan 07 '22 22:01 TrySound

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.

conartist6 avatar Jan 08 '22 00:01 conartist6

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

TrySound avatar Jan 09 '22 16:01 TrySound

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!?

conartist6 avatar Jan 10 '22 14:01 conartist6