Hey Yuri,
I think it would help knowing a concrete use case to help you figure out a
reasonable solution. Daniel has provided excellent advice, but the best
course of action depends more concretely on the exact situation to solve.
As Daniel mentioned, simplest way is write common.js for all your
On 2015-12-18 9:31 AM, Yuri Astrakhan wrote:
> Trevor and Daniel, thanks for your reply.
>
> How would you structure the code that is to be shared? Should it be a
> separate NPM package, referenced from the extension package.json via git
> url, and have a small file in the extension's lib/ dir
I had used returnExports pattern defined in https://github.com/umdjs/umd to
get a module that works in Node, AMD and browser globals.
That repo has several patterns and tools for this and you may find useful
to solve your usecase.
Thanks
Santhosh
___
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
On 2015-12-18 8:41 AM, Trevor Parscal wrote:
> 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
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
Trevor and Daniel, thanks for your reply.
How would you structure the code that is to be shared? Should it be a
separate NPM package, referenced from the extension package.json via git
url, and have a small file in the extension's lib/ dir with a oneliner -
"require('...')" that browserify