Comments (7)
I tried something right after I posted this. If I set 'localforage' as an alias to localforage.min in my requirejs config, it works fine:
requirejs.config({
"baseUrl": "js/lib",
"paths": {
"app": "../app",
"localforage": "localforage.min"
}
});
requirejs(["app/main"]);
app/main.js
define(["localforage"], function(lf) {
console.log(lf); // => Object { INDEXEDDB="asyncStorage", LOCALSTORAGE="localStorageWrapper", WEBSQL="webSQLStorage", more...} main.js (line 3)
});
from localforage.
Not sure, but since you're specifying .min requirejs may assume that .min is the file extension. Try require(['localforage.min.js'], though the config approach is a better one imo.
from localforage.
Oh sorry, didn't notice that your console.log was being executed. But this appears to be a requirejs bug and not a problem with localforage.
from localforage.
@jrburke Any chance you could fill me in on if this is a require bug/quirk or something I've done wrong? Does requiring localForage as "localforage.min" cause errors? Keep in mind if define
is available localForage does:
define('localforage', function() {
return localForage;
});
from localforage.
@tofumatt it is best if the define calls are anonymous in source form, so just define(function(){...
. That will allow 'localforage.min' references to work.
In the larger picture, I also suggest for consumers of this lib that are using modules to use 'localforage' as the ID as that plays well with any other library that might want the same (they will just ask for 'localforage' anyway, will not know about if minified), and if a minified version is wanted, use a paths config, as the second comment does, to point to that minified version.
And going a step further, I would not use the minified version in source form in a project: I suggest using the non-minified forms in source, then rely on an r.js build step to do any minifications. This allows better debugging if you need to step into the source of a dependency, and the whole project minification will lead to better results over just specific files being minified.
But back to the more immediate question, an anonymous define() call is best practice. More details here.
from localforage.
As said above, an anonimous define will fix the issue. I'll make a PR when I have some time if no one dibbs on that.
from localforage.
Works for me.
from localforage.
Related Issues (20)
- Doesn't work in electron environment when offline HOT 1
- How to add items without a key in localForage api?
- Make a new release with latest code HOT 3
- npm module
- A more efficient way of encoding binary data as strings in localStorage
- Why not use the textencoder api in the source code HOT 1
- LocalForage prevents sites from going to sleep
- Add a warning or an error message when setItem crash ? HOT 1
- Add src and more files to npmignore
- Error: Uncaught (in promise): VersionError: The operation failed because the stored database is a higher version than the version requested. HOT 2
- Local forage completely breaks my application
- vulnerability in localForage HOT 2
- Store and retrieve javascript objects?
- Is this repository still alive? HOT 1
- TypeError: Cannot read properties of null (reading 'db') HOT 1
- When is version and indexing supported?
- Can it support setting a validity period for the cache? HOT 1
- redes sociales
- Is this still supported? It has been 3 years? HOT 9
- chrome 121, can't getItem HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from localforage.