ResourceLoader is happy to ring files to the client from anywhere below the
base path you set when creating a file module. If that base path js the
root of the extension then you can just put the shared js code in a folder
accessible by both node.js and ResoriceLoader, maybe a /lib folder or
something.

Be careful when doing this with NPM modules, as their contents are subject
to change, and only their index file is configured and trying to
automatically know the paths and inclusion order is more of a mad science
than an art. Your best bet would be hard-coding and using very specific
versions in your package.json to protect from unexpected changes dues to
subtle NPM module version differences.

As for needing some $.extend, URL parsing and reconstructing, and logging.
I'm assuming you mean taking client code to the server where jQuery and
common browser functionally might not be present. There are many NPM
modules that provide shims for these things, including full-on server-side
jQuery. Usually the differences are subtle if any. Members of the Paraoid
team are very familiar with this space and are probably good people to talk
to about this.

- Trevor

On Friday, December 18, 2015, Yuri Astrakhan <yastrak...@wikimedia.org>
wrote:

> For JS gurus - what is the best way to share JavaScript library code
> between the NodeJS and browser?  The shared library will need to use
> $.extend()-like functionality, URL parsing and reconstructing, and logging.
>
> How should the code be organized? What are the recommended tools to
> automate the process?
>
> Thanks!
> _______________________________________________
> Wikitech-l mailing list
> Wikitech-l@lists.wikimedia.org <javascript:;>
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to