Maven like dependency management for browsers
Behrang Saeedzadeh
behrangsa at gmail.com
Sat Aug 8 05:42:54 UTC 2015
I still haven't looked at JSPM/SystemJS thoroughly, but regarding your
comment, I personally prefer the dependencies get resolved automatically.
For example, we can have www.example.com/app-deps.json where app-deps.json
contains something like this:
{
dependencies: [
{
name: 'backbone',
src: 'www.example.org/backbone.js',
dependencies: [
{
name: 'underscore',
src: 'www.example.org/underscore.js'
}
]
}, {
name: 'jquery-ui',
src: 'www.example.org/jquery-ui.js',
dependencies: [
{
name: 'jquery',
src: 'www.example.org/jquery.js'
}
]
}
]
};
Then we can use a loader system to load the dependencies:
Loader.load('www.example.com/app-deps.json');
Now this only works efficiently if we have a central repository similar to
Maven, otherwise there will be a request hell for each app/page/site to
download these dependencies. But if they all point to the same
CDN/Repository or use IDs+MD5/SHA1 hashes rather than URLs (e.g.
org.backbone:backbone:1.0), it will help the browser to avoid downloading
the same version of the same library more than once just because one is
fetched from foo.com/backbone-1.0.js and the other one from
bar.com/backbone-2.0.js.
On Sat, Aug 8, 2015 at 1:53 PM Garrett Smith <dhtmlkitchen at gmail.com> wrote:
> On 8/7/15, Behrang Saeedzadeh <behrangsa at gmail.com> wrote:
> > Hi Sebastien,
> >
>
> Guys —
>
> > On Sun, Aug 2, 2015 at 10:38 PM Sébastien Cevey <
> seb.cevey at guardian.co.uk>
> > wrote:
>
>
> [...]
>
> >> Versions can be specified either at the top-level config, or even at the
> >> import level, e.g.:
> >>
> >> System.import('npm:lodash at 3.10.0').then(function(_) {
> >> console.log(_.max([1, 2, 3, 4]));
> >> });
> >>
> >>
>
> That looks like the client (browser) would need to fetch the
> dependency list and mapping?
>
>
> Declarative chain of responsibility pattern was proposed years ago.
> The idea is different: It works more like ANT <target>s, where
> dependencies are declared right there in the document itself.
>
> The thread got some noise and then it died.
>
> <script src="fabric.js" async id="fabric">
> <script depends="fabric"> alert("loaded!"); </script>
> --
> Garrett
> @xkit
> ChordCycles.wordpress.com
> garretts.github.io
> personx.tumblr.com
>
--
Best regards,
Behrang Saeedzadeh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150808/8a3d0b5d/attachment-0002.html>
More information about the es-discuss
mailing list