> I also added an example using require.js.  I haven't fully tested, but I
> think this is the direction that best helps modularize openpgpjs.

I think require.js is a step into the right direction, but it's missing a
few features we might be interested in. Namely, it does not allow
optional dependencies, which would be useful for compiling a trimmed
down version of the library.

I'd envision something along these lines:
module('openpgp_packet_compressed',
   ['zlib', 'openpgp_packet'], // A list of mandatory dependencies
   ['lzma', 'bzip'], // optional dependencies
   function(zlib, openpgp_packet, lzma, bzip) {

   var exports = function() {
      this.tagType = 8;
      // ...
      if(bzip != undefined)
          // Compress as bzip
      // ...
   }

   return exports;
})

Later invoked as:
module('some_other_module', ['openpgp_packet_compressed'],
   [], function(openpgp_packet_compressed) {

    var packet = new openpgp_packet_compressed();
})

I've written a small library that does things similarily
https://github.com/dreamingofelectricsheep/tags.js
_______________________________________________

http://openpgpjs.org

Reply via email to