Maven like dependency management for browsers
Mohan.Radhakrishnan at cognizant.com
Mohan.Radhakrishnan at cognizant.com
Sun Aug 2 02:32:49 UTC 2015
But Maven has many more facilities like the 'Bill of Materials'(BOM) that doesn't need a version. Moreover the dependencies are handled based on the project lifecycles like 'compile','test' etc.
From: es-discuss [es-discuss-bounces at mozilla.org] on behalf of Behrang Saeedzadeh [behrangsa at gmail.com]
Sent: Friday, July 31, 2015 4:20 PM
To: Sébastien Cevey; EcmaScript Discuss Mailing List
Subject: Re: Maven like dependency management for browsers
JSPM and SystemJS, IMHO, are not as elegant as the way Maven (Java) or Bundler (Ruby) can manage dependencies.
Apologies if the following explanation is redundant and you already know how Maven works, but just for the sake of wider audience I will briefly explain it here.
In Maven, each library is resolved by its coordinates: group id, artifact id, and version. For example, the Google Guava library is made of the following coordinates:
Group ID: com.google.guava<http://mvnrepository.com/artifact/com.google.guava>
Artifact ID: guava<http://mvnrepository.com/artifact/com.google.guava/guava>
The short form notation is com.google.guava:guava:18.0.
Guava itself might depend on other dependencies, but you don't have to explicitly require them in your project. As long as you specify you require com.google.guava:guava:18.0, all its dependencies are added to your project automatically.
Most open source libraries are available in the Maven Central repository which is enabled by default. Users can additionally specify other repositories that Maven should query in order to find libraries with specific coordinates.
In SystemJS, baseURL looks similar to the notion of a Maven repository, but it is not as elegant: you can't have multiple baseURLs (if I am not wrong), and dependencies are specified relative to the baseURL, not as absolute coordinates and not versioned.
I am looking for something similar to SystemJS that can be used like this:
The call to System.import('com.modernizr:modernizr:2.8.3') will first query cdn.w3c.org<http://cdn.w3c.org> for com.modernizr:modernizr:2.8.3. If found, it will use that, if not it queries cdn.google.com<http://cdn.google.com> and then cdn.example.com<http://cdn.example.com> until it finds it or fails.
Similarly the call to System.import('com.jquery:jquery-ui:1.11.4') will do the same thing, but as jquery-ui depends on jquery, it will also download that.
One benefit of this compared to what is already out there is that at the moment if Site A uses CDN 1 for loading jQuery v1 and Site B uses CDN 2 for the same version of jQuery, the browser has to download both versions. But with this approach, as long as both sites depend on com.jquery:jquery-ui:1.11.4 it only has to be downloaded once.
On Thu, Jul 30, 2015 at 7:14 PM Sébastien Cevey <seb.cevey at guardian.co.uk<mailto:seb.cevey at guardian.co.uk>> wrote:
Have you had a look at JSPM and SystemJS? They cover similar grounds in userspace, with the intent for SystemJS to be the upcoming standard Module Loader.
On Thu, 30 Jul 2015 at 09:59 Behrang Saeedzadeh <behrangsa at gmail.com<mailto:behrangsa at gmail.com>> wrote:
Has this been discussed before? In a nutshell this diagram illustrates the idea:
* Rather than referencing a url in <script> or <style> tags, we require the browser to load name-spaced, versioned libraries. For example: com.jquery:jquery:1.0.
* This can either be done using the <script>/<style> tags similar to <script module="com.jquery:jquery:1.0"/> or <style module="com.jquery:jquery:1.0" /> or probably programmatically too: (in a JS file: require "com.jquery:jquery:1.0")
* There will be a central placed governed by W3C, for example, that can host libraries. Third-party repositories could also exist and be used (e.g. <script module="com.jquery:jquery:1.0" repository="cdn.jquery.com<http://cdn.jquery.com>"/>
* One benefit of this is dependency management. If jquery, for example, depends on lodash, it also gets downloaded and loaded automatically.
This is just the core of the idea. Nothing new (already similar systems are available for Java, Node, .NET, Ruby, etc.) but this will bring it to the web.
What do you think?
es-discuss mailing list
es-discuss at mozilla.org<mailto:es-discuss at mozilla.org>
Visit theguardian.com<http://theguardian.com>. On your mobile and tablet, download the Guardian iPhone and Android apps theguardian.com/guardianapp<http://theguardian.com/guardianapp> and our tablet editions theguardian.com/editions<http://theguardian.com/editions>. Save up to 57% by subscribing to the Guardian and Observer - choose the papers you want and get full digital access. Visit subscribe.theguardian.com<http://subscribe.theguardian.com>
This e-mail and all attachments are confidential and may also be privileged. If you are not the named recipient, please notify the sender and delete the e-mail and all attachments immediately. Do not disclose the contents to another person. You may not use the information for any purpose, or store, or copy, it in any way. Guardian News & Media Limited is not liable for any computer viruses or other material transmitted with or as part of this e-mail. You should employ virus checking software.
Guardian News & Media Limited is a member of Guardian Media Group plc. Registered Office: PO Box 68164, Kings Place, 90 York Way, London, N1P 2AP. Registered in England Number 908396
This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful. Where permitted by applicable law, this e-mail and other e-mail communications sent to and from Cognizant e-mail addresses may be monitored.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss