isaacs / node-primordials

https://isaacs.github.io/node-primordials/
11 stars 3 forks source link

Consider splitting index.ts into multiple files? #4

Closed jcbhmr closed 1 year ago

jcbhmr commented 1 year ago

If index.ts were to be split into multiple files, this would greatly add manual tree-shaking for CJS users https://web.dev/commonjs-larger-bundles/ and also assist in splitting the massive file into component parts.

Before I found this existing project today, I had made some progress towards my own @jcbhmr/node-primordials npm package: https://github.com/jcbhmr/node-primordials/tree/esm/src where I tried to split things into class-based or namespace-based files. Plus a util.ts for all the helper things, but that could be split down even farther if needed.

isaacs commented 1 year ago

Sure, patch welcome.

jcbhmr commented 1 year ago

I went ahead with my own package and made it into this: https://github.com/nodefill/primordials -- it goes into a bit of a different direction than I originally described 👆 in the Issue above since it exposes every single thing as an individual file as opposed to grouped files. I could make it so that each Array.js file also exported ArrayPrototypePush etc stuff too... 🤷‍♂️ lmk what you think

Pros to this:

Cons to this:

Some other differences of https://github.com/nodefill/primordials:

I'd love to somehow merge these two projects together since I think they are both trying to accomplish the same thing.

I've invited you as a Collaborator thingie on GitHub. You don't have to accept; my feelings won't be hurt ❤️