isaacs / node-lru-cache

A fast cache that automatically deletes the least recently used items
http://isaacs.github.io/node-lru-cache/
ISC License
5.38k stars 353 forks source link

build: remove bundler and unnecessary package.json fields #211

Closed SuperOleg39 closed 2 years ago

SuperOleg39 commented 2 years ago

Motivation

Minification, tree-shaking and modern ES transpilation for libraries is unnecessary, because all bundle optimizations it is the responsibility of the app developers. We, as library authors, just need to provide clean and modern source code, preferably in ESM.

size-limit use esbuild under the hood, and make optimization on their own.

One more important thing, lru-cache code is completely universal.

Also, webpack bloats the code a little bit with own runtime code.

For these reasons, I removed webpack build and "browser" package.json field.

package.json "exports" field is necessary when we provide code for different environments - CJS, ESM, browser specific. Also, "exports" useful as public library API layer, when library have a lot of modules in source code. Both cases do not apply to lru-cache library at this moment.

In which case it is still necessary to add bundler:

SuperOleg39 commented 2 years ago

If it is still necessary to keep the bundler, I have few advices:

isaacs commented 2 years ago

Thanks for the cleanup, I think that was kind of just there to check out how it works. I was considering using this approach on a larger project, and wanted to see it with something smaller first 😅

JounQin commented 2 years ago

I suppose webpack.config.js should be deleted at the same?

Besides, this is actually a breaking change for the users who're using lru-cache/browser entry.