> How about from a non browserify'ed script?

resources/openpgp.js already exposes a require function and the module name
"openpgp".

This would look like:

<script src="../openpgpjs/resources/openpgp.js"></script>
<script>
  var openpgp = require('openpgp');
</script>

> How do I access the bundled resources/openpgp.js from another browserify'ed
> bundle?

Your test.js:

var openpgp = require('openpgp');

Need to tell browserify to ignore module 'openpgp':

> browserify -x openpgp -r ./test.js:test -o testBundle.js

This creates a testBundle.js with the module name "test" which has openpgp as
external dependency and can be used as:

<script src="../openpgpjs/resources/openpgp.js"></script>
<script src="./testBundle.js"></script>
<script>
  var test = require('test');
</script>

You can also include everything in one bundle:

test2.js:

var openpgp = require('../openpgpjs/');

Here we reference the root directory of the OpenPGP.js repo with the
package.json
that contains the module definition.

browserify -r ./test2.js:test2 -o test2Bundle.js

test2Bundle.js has complete OpenPGP.js lib + test2.js coding bundled in a module
that exposes require function and module name "test2"

Usage:

<script src="./test2Bundle.js"></script>
<script>
  var test2 = require('test2');
</script>


Thomas


On Sat, Dec 7, 2013 at 8:14 AM, Robert B. Nelson
<[email protected]> wrote:
> I just started working in the devel branch and I have a couple of questions.
>
> How do I access the bundled resources/openpgp.js from another browserify'ed
> bundle?
>
> How about from a non browserify'ed script?
>
> I looked at the unit tests but they just include the openpgp source in their
> bundle.
>
> I played around with -x when building the client bundle but could never get
> it to work, I kept getting cannot find module errors where the module was
> some random collection of characters.
>
> _______________________________________________
>
> http://openpgpjs.org
> Subscribe/unsubscribe: http://list.openpgpjs.org
_______________________________________________

http://openpgpjs.org
Subscribe/unsubscribe: http://list.openpgpjs.org

Reply via email to