cloudhead / node-static

rfc 2616 compliant HTTP static-file server module, with built-in caching.
MIT License
2.17k stars 245 forks source link

neodoc is a massive dependency #228

Closed woojoo666 closed 3 years ago

woojoo666 commented 3 years ago

One of the things that appealed to me about node-static is the small size (as compared to other options like http-server and serve). A bare install on my machine results in a total node_modules size of ~200kb. However it looks like @brettz9 's recent changes will increase that significantly, since his fork @brettz9/node-static has a size of ~1400kb. The vast majority of this is from neodoc, which adds about ~1000kb alone.

Now don't get me wrong, I understand the change was to fix the security issues in the now-deprecated minimist (correction, optimist) package. All of @brettz9 's changes were a massive improvement to the project. However, I wonder if we really need to increase the size of the package 7x for a CLI utility.

Are there any other CLI utilities that we can use? Alternatively I guess we could just create a fork that doesn't include the CLI features, for people that just want the static server (like me).

brettz9 commented 3 years ago

Oh, wow, that does seem rather large. Yeah, I agree, we should be able to do better for size.

If it's agreeable to folks, I can perhaps look to switch to command-line-args: 112 KB unpacked ; https://bundlephobia.com/package/command-line-args@5.1.3 .

woojoo666 commented 3 years ago

Sounds good to me. From what I saw in the source code, it looks like we only need it for command line argument parsing anyways. Another option I know of is Commander.js, slightly bigger (143kb) but actively maintained and extremely popular. Alternatively, we can use the minimist package (which was a part of the deprecated optimist package that we removed). It's also very popular but much smaller (~32kb), although it hasn't been updated in over a year.

Here's a comparison of other popular options. Though ultimately I don't think we need to split too many hairs on this.

brettz9 commented 3 years ago

I've posted #230 (which builds on top of my ESM PR, #229).

I prefer to work with command-line-args (or rather my light wrapper on top of that and command-line-usage, command-line-basics), both as I like its approach in being modular and in offering a declarative, schema-like approach which makes for simple readability given JS syntax-highlighting (and requires less parsing within the library). (One can also build HTML or SVG of the docs using command-line-publish, but I didn't use that as we already have the README).

Feel free to let me know if that looks good for you.

Now that #229 uses Mocha, we can get binary file coverage, so I'd hope that we could get more binary tests added (mostly mirroring the programmatic ones) to give us assurances that the binary changes are working as expected.

woojoo666 commented 3 years ago

@brettz9 looks great, thanks for the quick release!! And yes I definitely like how the option definitions are declared now. Looking forward to seeing this in the next version!