Closed eastridge closed 13 years ago
This is actually a design flaw in what Ender assumes about the package.json structure. Using ViewJS as an example, the command line utils that ViewJS provides requires other NPM packages (coffee-script, etc). Removing these will break the ViewJS package, but leaving them in means Ender will try to include them when running "ender build". Any NPM package which has both command line or server components AND a bundleable client side JS library will likely run into this same problem.
Suggestion: add a "enderDependencies" key which has precedence over the "dependencies" key in a package.json file.
that's not a bad idea. obviously we're trying to minimize the amount of keys Ender takes up in the package configs. maybe we can have the ender
key optionally be an object, with a "main" key that points to the bridge and have its own set of dependencies
++ having an "ender" key which can be a string or object. I'd recommend supporting "bridge" and "dependencies" keys within that object instead of "main" though. I tried to create a patch for this but it looks like FILE.constructDependencyTree is still looking at the node_modules contents for dependencies and not the packageJSON contents.
it's hard to say what to do right now until @fat commits his working branch (that i'm not sure really exists)
haha oh really!
:D
I think overloading the ender key is the wrong decision here, as the problem would still exist unless we stopped using the dependency param altogether -- which is obviously a bad idea -- we'd lose support for lots of important libs like backbone, mootools, etc.
I think it's incredibly uncommon for the microlibs to include a cli in the same repo. Can either of you think of another example? Also are you sure the cli stuff shouldn't be a devDependency? I don't think it belongs in the dependency property if the view.js doesn't depend on it.
oh wait... i missed the bit about it taking precedence... hm...
In terms of syntax, if it was backwards compatible (i.e. you could still pass a string, and the root dependencies would still be used if the ender.dependencies key was not present) I don't see the downside. Certainly every potential configuration option for Ender hasn't been thought of yet, so having an object to add options to later would not be a bad thing.
As for another lib that does something similar: Ender. The difference being that you've split off the client side JS into a separate npm module which I don't want to do with my package. I think it's also fair to argue that as the ender/npm/node ecosystem matures that we will see more modules that involve both a client and server (or CLI) component. CoffeeScript is another example I can think of although I do realize that you should be pre-compiling all your .coffee files and should never need to use it.
There isn't a technical reason to do so, but ender could be self consuming if you added this option (i.e. move ender-js into ender).
I was unaware of the devDependency param, but that doesn't look like it fits my use case. Thanks for the suggestion though.
Oh, and the problem that triggered all of this in the first place (the ".bin" directory) goes away for me if I can specify what dependencies Ender is looking for, but I suspect that the ".bin" directory and possible any other ones npm is using internally should be ignored. Though I don't know if there are any special ones it creates besides that.
AND I'll start hitting the "Comment" button instead of the "Comment & Close" button at some point....
Ender now only adds dependencies to the dependency tree that are defined the package.json of a given module. This solves the .bin directory issue.
I'm closing this issue (because that solves the issue topic -- but i'll open another one about the ender object key in the package.json
The package "view" includes other modules which have associated bin scripts. This creates a ".bin" directory in view's node_modules directory.
npm install view -g ender build view
Will throw error: "something went wrong while trying to read node_modules/view/node_modules/.bin/package.json"
In ender.file.js I've added this check which fixes the problem for me:
I'm not going to do a push request for this because it seems like there needs to be a more comprehensive check somewhere.
Thanks - Ryan