Monday, May 28, 2012

Dart Pub for Local Development

I got a nice taste of the pub packager for Dart (it's so new, it has a commit, not a landing page). Like just about everything else in Dart, pub is starting small, with just enough to get an idea how it might work, but not so much that it is at all encumbered by previous implementation.

Tonight, I'd like to see how far I can push the current implementation. Specifically, I would like to see if I can make it manually emulate npm's very excellent npm link. The "link" in that command instructs npm to link a local copy of a package instead of installing it from the npm registry. It is more than installing it from a local copy—it creates a symbolic link to the local package instead of installing it. The invaluable benefit of this approach is that any changes made to the linked package can be immediately committed without the intermediate step of copying them into a separate repository.

I do this constantly as I am developing Hipster MVC. Try something new in Dart Comics / tweak the code in Hipster MVC. Struggle with an implementation aspect in Dart Comics / update the documentation in Hipster MVC.

But until now, this has been a pain. I either need to update the code on GitHub to see the change locally:

That is pretty freaking amazing. If there is anything even close in client-side Javascript land, I am unaware. But even is a pre-release / proof-of-concept, the pub packager already makes life oh-so-sweet for the Dart developer.

Nice! Built-in support for sym-link development is gonna be big. Really exciting.

I slightly prefer the npm-link approach. Both are two step processes — npm link once in the repo + once in the target project, while pub would be edit pubspec + pub install / update. The main benefit of the former is that it leaves no residual to be cleaned up before committing changes to SCM. Also, both operations are shell instead of one file edit + one shell.

My concern is only the pubspec file. I agree that it's a minor thing, but I worry that I'll end up checking in a pubspec file modified for local development. I can see something like a pubspec change getting lost in the wash of a large commit.