Navigation to actual definition rather than the import (require), when using CJS modules and module.exports
In WebStorm, I used to be able to jump from a usage of a binding to the actual place of the binding, with the AAPL-click combo. Example:
myModule file:
const foo = x => 2 * x
module.exports = { foo }
user file:
const {foo} = require('./myModule')
...
const bar = foo(128)
^
In this case I want to jump from the mention of foo in the user file to where the foo is defined in myModule. IIRC we used to have the option to even select whether we want to jump to the immediate definition in context (the top require in the user file) or directly to its origin. I don't remember if I used ES2015 import / export or CJS modules when it worked. Now it doesn't work with CJS module.exports / require - is it possible?
请先登录再写评论。
https://youtrack.jetbrains.com/issue/WEB-31441 is fixed in 2018.1.2 - can you try it?
Elena, awesome, thank you, the new version works just as you told! Also, Option-Cmd-B still allows me to jump to the local `{foo} = require('./myModule')` if need be, so we're having this feature both ways.