This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
If I have NodeJS project, where Sources == project dir and there is a node_modules folder in sources, it would be handy to offer node modules from node_modules folder in var e = require("^"); it can be achieved now using relative file paths, but for locally installed modules, this is not necessary and probably also not common. Example: [project dir] -- node_modules -- body-parser -- test.js -- test2.js in this case I have a body-parser module and it contains test.js and test2.js. The code completion would offer #1 var e = require("^"); => NodeJS core modules, file paths (as it does now) and also body-parser, once I select body-parser, it would be completed w/o "/" var e = require("body-parser"); #2 var e = require("body-parser/^"); => cc would offer test.js, test2.js There can be node_modules folders inside of some other module folder, but only the single top level node_modules in project/sources dir (I guess package.json will be in most cases in the same folder as node_modules) would be used for #1. The #2 is "just about mapping" resolved path to file paths. I have no idea of any performance implications, but at least #1 would be imho very nice :) Thanks
Regarding the performance, it can be "cached" in the index in the worse case. But it should be tested. If I summarize is. If there is a node_modules folder in the project, offer the names of the child folders in the code completion, in the empty string in require or define method. Is it right?
(In reply to Petr Pisl from comment #1) > Regarding the performance, it can be "cached" in the index in the worse > case. But it should be tested. Probably, it won't change that often but in case it does, would be nice to somehow force refresh :) > If I summarize is. If there is a node_modules folder in the project, offer > the names of the child folders in the code completion, in the empty string > in require or define method. Is it right? Yes, but probably makes sense to use just the one main node_modules in project/sources dir (not "nested" node_modules in individual module's folders). I guess only exports method makes sense, not define Thank you
The first part is in the web-main now. The implementation now looks for the first node_modules folder that is up to the edited file. If such folder is found, then all children folders of node_modules (containing package.json file) are offered in the code completion. From the package.json file is constructed the documentation. Now includes the module name, version and description. It can be included more if you want. Also Go To Declaration works(CTRL+click). In such case the editor opens the file, which is defined in the package.json as main file. Vlado, this is already second Christmas present for you :).
Thank you, I guess I've been good this year :) It works great
Integrated into 'main-silver', will be available in build *201412190001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/af9ee840f5d0 User: Petr Pisl <ppisl@netbeans.org> Log: #249269 - Offer local node_modules in require() code completion First part implemented