medikoo / memoizee

Complete memoize/cache solution for JavaScript
ISC License
1.73k stars 61 forks source link

Non npm/build-library file? #90

Closed PandaWood closed 6 years ago

PandaWood commented 6 years ago

I feel incredibly stupid here, but I'm working on an old project with no webpack or build tool. And I cannot understand how to include this library. I wonder why there is no single file for inclusion in the release or that can be built?

Have I missed anything - or is there really no catering for us simple downloaders ? (ie normally there's a "src" folder and/or "dist" folder or one that can be built)

medikoo commented 6 years ago

@PandaWood this was developed with high modularization in mind in already a Node.js era. Where organizing dependencies with small external files seemed a way to go (and a huge step forward when looking at how we dealt with scirpts In _old days).

Anyway you can easily build such standalone library file. I'm not exactly sure how to do it with Browserify or Webpack (refer to their documentation, as for sure it's possible), but with Webmake it'll be as:

$ npm install memoizee
$ webmake --name=memoizee node_modules/memoizee/index.js > memoizee.js

I do not document this in doc, as it's not recommended approach in sense that you can easily end with code duplication in your app. e.g. imagine that you also want build for other library, e.g. named foo, that shares dependency with memoizee. Now taking both memoizee and foo as individual build files, will result that code they share is loaded twice in a browser, not very effective.

That's why it's wiser to have one application file bundle.