Modules as unit of deployment != modules as unit of development

Jul 13, 2012 at 3:08 PM

Take a look at knockout.js https://github.com/SteveSanderson/knockout/tree/master/src

Knockout provides an AMD module (https://github.com/SteveSanderson/knockout/blob/master/build/fragments/amd-pre.js#L9)

However, the source code is not smashed into one massive js file. It's separated out into logical pieces. A build script joins everything together into a single "module" file.

I believe that techniques such as CommonJS and AMD provide great solutions for modules as units of deployment, but aren't as good for units of development.

The Knockout source uses a hierarchy of objects to organize itself, all hanging off a single top-level `ko` object.

I'm not sure how useful this is for Hilo, but I though the distinction between development and deployment was worth considering.

Jul 16, 2012 at 2:09 PM

That's a great point.

I do this in my Backbone plugins (Marionette for example), but I had never really thought about this as a legitimate pattern for deployment vs development. 

This does bring up the question of whether or not we could do something like this with Hilo. Is there a way that we could incorporate a build tool to merge files together, as part of the build process?

Is there any benefit to this, as well, since we're running on the device directly and not downloading via a potentially high-latency network? What are the ramifications for performance of having a large number of files, each with their own module definition wrapper vs joining the files together and reducing the number of wrapper functions / module definitions.

It would be easy enough to set up a performance benchmark and test out the end result.

Thoughts and opinions?

Coordinator
Jul 16, 2012 at 8:12 PM

For Hilo, I don't think we're concerned with units of deployment, just the units of development. 

  • Regarding the question of build process: we can run tasks (msbuild) whenever the jsproj file is processed (F5 in VS). We could combine scripts then (as well as things like Sass, CoffeeScript, etc.).
    However, the jsproj won't be processed during an app refresh (Ctrl + Shft + R in VS). Refreshing is a general part of my developer rhythm. Maybe that's not a big deal though. 
  • Regarding performance and scripts:
    http://msdn.microsoft.com/en-us/library/windows/apps/hh849088.aspx

I think we'd all agree that fundamentally a namespaced object is a unit of development. The big question for me is:

Do we need/care to isolate WinRT dependencies? If so, how?