However, there is generally one hurdle when doing this. Some modules depend on code or third party modules that are server specific. When bundling (act of preparing for the browser) these modules it would be wrong to include these server only modules. Instead, the bundler tool needs to be able to shim out those 3rd party modules in favor of alternate code which replicates the functionality in the browser. Currently tools like browserify and script allow you to do this manually in your code. This is error prone as you have to know the dependencies for any thrid party modules you use and track if you need to shim them out or not. Instead I propose that we "standardize" and put this information into the package.json file so that any such bundling tool (and other tools) will know that when the code is bound for a browser, certain modules should be replaced.
Imagine a package.json with the following dependencies:
The module author would now be able to provide the following additional section (if needed):