You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 25, 2018. It is now read-only.
This is just my naive proposal but I'd like to suggest 2 things:
Install modules with their version in the path: node_modules/moment/1.4.8/index.js
Add a 2nd parameter to require(<module>, <version>) for requesting a specific semantic version
Potentially add requireVersion(<module>, <version>) specifically for this
require('./module') would be equivalent to: require('./module', '*')
I've never used * in package.json, does it take the latest version or the first it finds?
Note: Modules sometimes change names, so you'd see node_modules/extendr/1.4.2 and then node_modules/extendible/1.4.3. A later version with a different module name would NOT go to the same node_modules/extendr.
I believe this would make it possible to install all dependencies in the first level of node_modules and allow loading modules like slots.
My reasoning is that if you need a specific version of something it should be reflected in your source code, not just package.json.
This would be making a change to require() which is 'Locked', but because it's an optional 2nd parameter I think it's acceptable to meddle with. Previously I had thought require('./module', 'a', 'b', 'c') might pass those extra arguments to a module in arguments - but it seems not. Providing a version there would be a non-breaking change.
In the future one might want to provide arguments to modules: require('./module', 'a', 'b', 'c')
Maybe a separate function could be: requireVersion(module, version, arguments...)
Side-concern: npm ls --depth=0 would show all dependencies - not just your 'primary' dependencies. Some scripts might rely on this.
The text was updated successfully, but these errors were encountered:
Recently npm changed to install dependencies in a 'flatter' way.
https://docs.npmjs.com/how-npm-works/npm3
This is just my naive proposal but I'd like to suggest 2 things:
node_modules/moment/1.4.8/index.js
require(<module>, <version>)
for requesting a specific semantic versionrequireVersion(<module>, <version>)
specifically for thisrequire('./module')
would be equivalent to:require('./module', '*')
I've never used
*
inpackage.json
, does it take the latest version or the first it finds?Note: Modules sometimes change names, so you'd see
node_modules/extendr/1.4.2
and thennode_modules/extendible/1.4.3
. A later version with a different module name would NOT go to the samenode_modules/extendr
.I believe this would make it possible to install all dependencies in the first level of
node_modules
and allow loading modules like slots.My reasoning is that if you need a specific version of something it should be reflected in your source code, not just
package.json
.This would be making a change to
require()
which is 'Locked', but because it's an optional 2nd parameter I think it's acceptable to meddle with. Previously I had thoughtrequire('./module', 'a', 'b', 'c')
might pass those extra arguments to a module inarguments
- but it seems not. Providing a version there would be a non-breaking change.In the future one might want to provide arguments to modules:
require('./module', 'a', 'b', 'c')
Maybe a separate function could be:
requireVersion(module, version, arguments...)
Side-concern:
npm ls --depth=0
would show all dependencies - not just your 'primary' dependencies. Some scripts might rely on this.The text was updated successfully, but these errors were encountered: