168 points · by matthewmueller · 12y ago · 100 comments
I've worked on enough large projects that relied on prayer and optimism instead determinism when resolving dependencies, and eventually you end up losing hours or days trying to get the app running on a new server or a new developer's box.
Not requiring a manifest is a bug, not a feature. If people can specify dependencies, and information about the version used is lost, then you can be sure that it will happen in practice. Code designed for "proofs of concept" has a funny way of making it into production.
As we know from studies of things like organ donation rates, even the smartest humans get tired or distracted and make bad decisions. The only guard we have against it is choosing sane defaults. (See Yehuda Katz' RailsConf keynote for some interesting insight into how this interacts with convention over configuration: http://www.confreaks.com/videos/3337-railsconf-keynote-10-ye...).
While the simplicity of DuoJS allows it to win the Pepsi Challenge against other options, where the first sip tastes very sweet, I would never again willingly choose a dependency manager that makes reproducibility anything other than mandatory.
@tomdale We're on the same page. I've worked with many large JS codebases as well and consistency and repeatability are a must.
However, as with any tool, it's effectiveness comes from how you use it. There are so many NPM modules that use "*" in their manifests. That's not very robust. Having a manifest isn't a solution, it's how you use the manifest.
In Duo you can pin down any dependency right in the file via require('some/repo@tag'), which is the same as having a manifest with a pinned version.
With that being said, I'm open to any and all contributions or ideas on how to make Duo more consistent and repeatable. I love what Docker does for it's image builds and I think if we could get that kind of robustness going on the frontend, we would all benefit.
That will do nasty things for your ecosystem if people start doing that in libraries. You'll end up with version lock on shared dependencies:
- My app depends on foo and bar.
- foo and bar both depend on baz.
- They both specify different tags.
Now your solver has a sad, and your user has a sad.This may not be a problem on client side javascript if your dependencies don't export to the global object.
require("emberjs/ember-component@^1.6.1")
Doesn't this mean that to update an Ember package, I have to change every file that references that package? That would mean having to touch the JS file for every component in your project to bump the version.Am I missing something?
If a component.json is present, it'll use that to get the versions and you just require('emberjs/ember-component')
Duo falls back to the manifest if it cannot resolve the path on it's own.
For proof of concepts and hacks though, adding a manifest is a waste of everyone's time.
npm install foo --save-dev
When you go beyond a single developer playing around, having a quick, well-known place to look to learn what dependencies are being used is very useful.Does this have any more to offer other than deducting what to download&install from the dependency tree? Because if that's "all", it would be easily added to e.g. webpack, I suppose. Is it really worth making yet another dependency and build tool just for that one feature? If you build on top of webpack, you get a lot of stuff for free, like speedy and dependable file watching, hot-reloading development servers, support for nearly any imagineable frontend language, and a remarkably decent extensible architecture. All this has to be made again for Duo.
Both dependency management and frontend building are highly complex tasks. I'm not saying that therefore it couldn't be done better, but I do honestly, without judging, wonder whether the authors seriously considered existing solutions and ran into impossible problems, or whether this is just the Not Invented Here syndrome at work.
- Transparently supports modules from CommonJS, AMD, ES6 or globals.
- Enforce a manifest (config.js) that let you pin dependencies (incl. transitive dependencies) to exact versions. Unlike RequireJS config, jspm automatically manages that file for you.
- Support multiple package providers, e.g. NPM, on top of Github.
- Based on SystemJS, a polyfill for the upcoming standard System loader. This hopefully makes it future-proof.
- Does not require a compilation step: dependencies can be pulled dynamically from a CDN over SPDY. Alternatively they can be cached locally as well. A compilation step (jspm bundle) is still available.
- Works both in the context of Node and the browser.
We've been successfully using jspm and SystemJS in production at the Guardian. It's still early days, but the devs are very active and responsive.
This isn't meant to distract people away from taking a look at Duo and making up their own mind, but I noticed nobody mentioned jspm in this thread and thought people may want to look at both and compare.
npm install --save dep
With this, I either have to be satisfied with not locking down the version, or go lookup the current version manually before adding the reference to my code.
It also looks like upgrading a dep would mean changing every require.
In the case of Go, it's more meaningful to note that most larger Go projects have been developed for quite some time without needing any of these tools.
If you need specific versions, the standard, idiomatic Go approach is to vendor your dependencies. Google, for example, does not use any Go-specific tool for vendoring IIRC. The last tool you mentioned, Godep, is one Go-specific approach at vendoring. It's also the one that I have anecdotally heard recommended, but this comes with absolutely zero personal experience and is solely hearsay.
But most projects don't even need to vendor - I've been writing Go as my primary language for almost 2 years both at work and for personal use, and I have never once needed godep. YMMV, obviously.
(Looking at tools that exist isn't meaningful in se, because people will try to build libraries to replicate pattern from other languages whether or not they apply. They will look for what they're familiar with, see that it's "missing", and then decide to write one, rather than questioning whether that idiom is actually appropriate for this new language.)
It would be interesting for someone with more expertise to do a compare/contrast further down the line of all three.
"...I show you how deep the rabbit hole goes" - Morpheus
Also, does someone know how the Closure compiler fits into all of this? It might be totally unrelated but I'm trying to learn more about JavaScript application architecture, and I'm not sure where that fits in.
My Gulpfile has 200 lines and does everything from asset-manifests to css minification, js-reloading etc.
Dude, you're so behind the times. It's Yeoman and Bower now. Wait, Broccoli and Duo.
For example I created a quick index.js file and required angular and restangular. It immediately errored out because the angular.js repo doesn't use semver on it's master branch. Ok fine, switch to angular/bower-angular, nope, it looks for index.js so my require now has to read: require('angular/bower-angular:angular.js'). Run again, error, same issue with restangular, it's looking for index.js. That require now reads: require('mgonto/restangular:dist/restangular.js'). I had to actually find where the files are that I wanted to require and explicitly state them in the require. Shouldn't this automatically parse bower/component/package.json files for this info, especially if you're touting the 'No Manifest' thing.
More seriously: do you feel like it incorporates all the lessons of its predecessors?
Typically, let's say for an app, you'll run a watcher which will trigger the builder, so you can just spin it up and leave it alone. For smaller components that are meant for consumption, a simple Makefile is more than enough and running the command isn't too terribly bad.
Maybe it could. Maybe it could also work with `require('package@0.5.1')` and other sugars like this.
var uid = require('matthewmueller/uid');
as in the home page example, what gets bound to the uid identifier?
The point is that a package manager does not only need to fetch dependencies, but also to specify relations between modules. This is why, for instance, Bower only does half the story (fetching) and it has to be coupled with a tool like Require.js to actually provide modules.
In the frontend world there just isn't such a standardization on paths, and this is what makes it difficult to locate a module even when the Github repo for it has been downloaded.
How does Duo solve this issue?
1) Download https://github.com/matthewmueller/uid from github
2) Find it's entry using https://github.com/duojs/main
3) Parse it's entry, and extract the dependencies
4) Recurse
If so, manifests could be written in a very neat way. See: https://gist.github.com/aymericbeaumet/22c3a9deba54549821e3
Although there's no real benefit of doing that over using the manifest other than it's kinda cool :)
As a personal taste, I by far prefer to configure my application in a JavaScript file rather than a JSON file. And I consider dependencies as a part of the configuration process. It agrees with the Duo philosophy which aims to simplify the building process from A to Z.
Also, can you host your own "duo registry" (if the concept makes sense here). And if so, can you point to the private registry instead of using the public GitHub?
Bower and npm supports these, and that's what I'm using currently.
Point is, just use the git repos instead of needing that registry at all.
And considering that any real project needs a manifest, the versioning syntax doesn't seem especially compelling.
I'd like to be proven wrong, because this looks cool... but I don't see the value over npm and browserify other than some syntactical sugar (which could probably be achieved with an npm wrapper). Am I missing something?
here's a rabbit hole of additional information: https://github.com/npm/npm/issues/3014
:-)
I can't see why this is browser only, am I missing something?
On large frontend codebases, these tasks can take an annoyingly long time. Hence, some tools cache (e.g. see browserify vs. watchify).
Oh my. You've essentially killed Bower and NPM in one swoop then haven't you?
An exciting time to be a web developer to say the least, this looks simply amazing.