Git Product home page Git Product logo

Comments (13)

jpmckinney avatar jpmckinney commented on June 27, 2024

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.

jpmckinney avatar jpmckinney commented on June 27, 2024

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.

jpmckinney avatar jpmckinney commented on June 27, 2024

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.

dergachev avatar dergachev commented on June 27, 2024

James, have you considered ypenope.js? I found it a lot simpler than requirejs.
http://yepnopejs.com/

from ajax-solr.

jpmckinney avatar jpmckinney commented on June 27, 2024

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.

jpmckinney avatar jpmckinney commented on June 27, 2024

I created an issue on yepnope: SlexAxton/yepnope.js#161

from ajax-solr.

jpmckinney avatar jpmckinney commented on June 27, 2024

I also created an issue with headjs: headjs/headjs#231

Amazingly, the very old, no longer developed labjs works fine!

from ajax-solr.

jpmckinney avatar jpmckinney commented on June 27, 2024

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.

jpmckinney avatar jpmckinney commented on June 27, 2024

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.

jpmckinney avatar jpmckinney commented on June 27, 2024

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.

jpmckinney avatar jpmckinney commented on June 27, 2024

requirejs works now - I had the wrong syntax.

from ajax-solr.

dergachev avatar dergachev commented on June 27, 2024

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.

jpmckinney avatar jpmckinney commented on June 27, 2024

Oops, that was leftover from my earlier work. Keen eye! I've removed it now.

from ajax-solr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.