Right now everybody seems to be creating their own .json.
Here are the reasons I think it happens:
- node dependencies may be different than browser dependencies
- node main.js may be different than browser main.js
- {project} {something} may be different than {project2} {something2}
- {not-npm} feels like it has to be a parasite in an npm-centric package.json
I think #4 is the big one.
If there are other reasons, please let me know.
I'd like to stop doing this, and I think everybody else would too.
Here's how it could work:
Everybody, including npm, can use a namespace in package.json to override the primary values.
As I understand it, this is how volo, browserify and jam already do things, so lets consider two other popular javascript package managers. (Yes, I know browserify is not a package manager, but it is related to this problem.)
A package.json with bower being the primary target might look like:
{
"name": "tophat",
"version": "1.0.2",
"description": "you know you look best in a tophat",
"main": "tophat.js",
"dependencies": {
"es5-shim": "1.0.0"
},
"npm": {
"version": "0.2.1",
"dependencies": {}
}
}
Bower would install es5-shim
but npm would not because it doesn't need it.
Additionally, npm gets a pre-release version number because maybe node support
is still in development.
Finally, insofar as bower, jam, and volo share the same config, you only need to override for npm.
A package that targets npm first could look something like:
{
"name": "corsette",
"description": "you know you look best in a corsette",
"main": "index.js",
"bower": {
"main": "corsette-browser.js"
}
}
This approach of embedded, overridable package manager configs allows
- any package manager to "own" the package.json
- any other package manager to override the "owner" config
- authors to stop repeating themselves
Having 5 different .json
files in a project may seem like no big deal, but it
is causing friction with some, which means managing JavaScript dependencies is
harder than it should be. I think this is a solvable problem. Lets make things
simpler.
np, I think from a future-proofing perspective non-package.json may be the way to go, node will be coupled for quite a long time since the ecosystem is so large, so every package.json out there is pretty much frozen. This is pretty common in general with software though, you get stuck with legacy systems and every so often it's "healthy" to break completely free and start fresh. Hell even if we do that it will happen again in another 2 or 3 years for sure haha :D