Comments (13)
We would want to namespace require
to avoid conflicts. See http://requirejs.org/docs/faq-advanced.html and http://requirejs.org/docs/faq-optimization.html for options.
from ajax-solr.
Would have to wrap all files in define
blocks. In order for require.js to be optional, we would have to supply dummy implementations of define
and require
. It looks like require.js handles multiple files having the same dependencies just fine. The strategy would be for each non-abstract widget to define all its dependencies, so that users can just include the widgets and not worry about core files.
Try implementing this strategy in the demo site to see if it works.
from ajax-solr.
See the requirejs branch. Verdict is that requirejs will be too confusing to beginners and to people who don't need it. script
tags is best for beginners, and advanced users should just package/compile assets in production. requirejs just gets in the way during development, with its need to cache bust for example. Perhaps worst of all, it seems impossible to use requirejs without adding define
calls to every dependency, which means everyone needs to buy into requirejs for this to work.
from ajax-solr.
James, have you considered ypenope.js? I found it a lot simpler than requirejs.
http://yepnopejs.com/
from ajax-solr.
It is indeed simpler. I tried it in a new yepnope branch. It seems to download all the dependencies correctly, but when it executes the complete
functions, it starts with the one in reuters.1.js
(which breaks, because it expects all the other complete
functions to have run first). I would expect yepnope to run the complete
functions in an order that respects the dependency tree: i.e. run AbstractManager.js
's complete
, then Manager.jquery.js
's then reuters.1.js
. I'll try labjs, see if it works better.
from ajax-solr.
I created an issue on yepnope: SlexAxton/yepnope.js#161
from ajax-solr.
I also created an issue with headjs: headjs/headjs#231
Amazingly, the very old, no longer developed labjs works fine!
from ajax-solr.
Anyway, for the demo, I think <script>
tags still make the most sense. No need to educate people about script loaders to teach them ajax-solr.
If we were to integrate LAB for use by developers outside the demo, developers would need to set the LAB base path to the folder containing ajax-solr, because the paths to ajax-solr files are hardcoded:
$LAB.setGlobalDefaults({BasePath: '../../'});
All their other scripts would have to be relative to this base path. If another library required developers to set the LAB base path, it'd be impossible to satisfy both. This wouldn't be an issue if LAB had something like Yepnope's path filter. The solution to the conflict would be to define a AjaxSolrBasePath
global instead of using $LAB.setGlobalDefaults
(which is what I do in the labjs branch).
Anyway, I'm not sure LABjs is popular enough to bother adding this to ajax-solr. The only request has been for requirejs so far. If Yepnope or headjs fix their issues, we can maybe add those later.
from ajax-solr.
I tried require.js again, without using define
to create modules this time. It has the same bug as yepnope and head.js requirejs/requirejs#710 Maybe they consider it a feature?
from ajax-solr.
With some help from the maintainer, I got head.js working. See this fiddle for a small example: http://jsfiddle.net/TWDy4/2/
Update: The approach becomes very unwieldy, as you need to nest head
calls for each dependency. See e.g. reuters.3.js
from ajax-solr.
requirejs works now - I had the wrong syntax.
from ajax-solr.
James, I only quickly skimmed over your commits, but one thing stands out:
Does it make sense to call define twice in AbstractSpatialWidget.js?
https://github.com/evolvingweb/ajax-solr/blob/requirejs/core/AbstractSpatialWidget.js#L67
from ajax-solr.
Oops, that was leftover from my earlier work. Keen eye! I've removed it now.
from ajax-solr.
Related Issues (20)
- Add a widget that uses MoreLikeThis
- Support for SpellCheckComponent HOT 1
- Add a widget that uses TermsComponent
- Add a widget for multiselect facets with configurable operand
- Inheritance not working? HOT 5
- Websolr integration HOT 7
- Better escaping
- auto widget creation based on return factes HOT 1
- Demo not working HOT 3
- PagerWidget.js / ParameterHistoryStore.js / history.js IE Issue HOT 2
- Unable to fetch data from local solr application using ajax solr HOT 3
- Add a bower package
- ERROR: Cannot read property 'length' of undefined HOT 1
- Demo website broken? HOT 1
- Not able to fetch reuters data HOT 13
- Not able to show the Calendar widget HOT 2
- Phrase level autosuggestions using suggesters
- Demo Site Not Working HOT 6
- Ajax-Solr not work after change jquery.min.js 1.7.2 to newer version (1.11.2)
- Range widget
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 ajax-solr.