Lost Module

A while back (at least a month ago), Safari 5 was released. I often check out my javascript projects in new browsers to see if the environment is changing on me. It turns out that Naked Javascript and Canvas P.J.s both failed to run. The common element is that I’d been using both of them as test cases for my own javascript module loading system.

When I started looking at the code, I found I had an extra branch named ‘synthesis’ lying around. The code dates run approximately up to when I got organized, so I apparently I didn’t have time for fun little programming projects anymore. As best I can tell, it was working towards partial CommonJS compatibility, (and really knocking it out on January 9) so I merged back to default and continued with my current project.

Just what changed for CommonJS is a little fuzzy, but it’s clear that I changed to absolute paths by default, changed some names, and did a little to support ‘exports’

The difficulties with Safari 5 may have been due to more allowed parallel downloads, causing things to load out of order. I also tracked down some minor differences (every browser seems to do ‘onerror’ differently, for instance)

While hanging out in the file loading mental domain, I had an insight. However, it’s the kind of insight that could require scrapping the whole thing and starting over. It comes down to this: all the load operations can be reduced to recursive combinations of two operators: in-order and in-parallel. This isn’t a very new concept in general; I’ve seen it used for functional music composition systems, for instance.

All that happened around 2010-06-19. I finally got back to it yesterday. Digging into all the events going off, I couldn’t help but change things. Module.js is based on script loading, and it basically keeps inserting script tags until they succeed, or it gives up. This basically leads to parent and children playing leap frog as it completes each step. I rearranged things so that the parent isn’t retried until the child succeeds, which saves several steps.

Imagine my surprise when, finally getting a stable edit and tearing out the profuse logging, I got error messages from Mercurial on unrelated files. More bizarre still, the consistency checker pointed back around 40 revisions and 7 months. My best guess is that it was a version issue. I was able to download a stable repository from BitBucket, export the two missing changesets, and then replace the damaged repository in-situ in order to continue committing the continuation based resume.

And just when I think I’m done, I notice the CommonJS test suite I’d overlooked when coming back. It appears to have gone downhill a little.

Posted Sunday, July 18th, 2010 under Devlog.

Comments are closed.