Closed SuperOleg39 closed 2 years ago
If it is still necessary to keep the bundler, I have few advices:
rollup
produces more lightweight bundles"exports"
field need to be fixed, so that the bundler can automatically use browser
bundle when build code for browser environment, and working as "browser"
field, e.g.:
"exports": {
".": {
"node": "./index.js",
"browser": "./bundle/main.js",
"default": "./index.js"
}
}
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 😅
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.
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
useesbuild
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 tolru-cache
library at this moment.In which case it is still necessary to add bundler:
unpkg
orjsdelivr