the "localForage" library bundled as an ECMAscript module
This repository provides the localForage library as an ECMAScript module (ESM).
If you are used to importing external modules - even within browser scripts (e.g., in a no-build environment) - using the localForage library becomes difficult (see issues #831 and #976). And since the attempts to made relevant changes broke installations of existing users, all activities in that direction seem to have been stopped (see issues #940 and #977).
This repository therefore copies the source code of the original distribution and bundles it into an ECMAScript module - nothing else.
But now you can easily import localforage from 'localforage'
(or import localForage from 'localforage'
if you prefer that capitalisation) as shown below
<script type="importmap">
{
"imports": {
"localforage":"https://rozek.github.io/localforage-esm/dist/localforage.esm.js"
}
}
</script>
<script type="module">
import localforage from 'localforage'
...
</script>
Or, if you don't like import maps
<script type="module">
import localforage from 'https://rozek.github.io/localforage-esm/dist/localforage.esm.js'
...
</script>
You may easily build this module yourself.
Just install NPM according to the instructions for your platform and follow these steps:
- either clone this repository using git or download a ZIP archive with its contents to your disk and unpack it there
- open a shell and navigate to the root directory of this repository
- run
npm install
in order to install the complete build environment - execute
npm run build
to create a new build
That's it!
Please note, that the original source code is licensed under Apache 2.0 - and since I simply copy it and just build the library in a different way, this repository has that license as well.