Require js ruins code navigation

跟風遠走 提交于 2019-12-03 01:33:47

It's a known issue, please star/vote.

From the issue description:

The dojo library switched to AMD's format define() for loading modules instead of dojo.require(). Previously I was able to use Ctrl+B on dojo.require('path.to.someJs') to jump to the declaration. This does not work on the new format define(['path/to/someJs]', ...).

As PyCharm, WebStorm, PhpStorm and IntelliJ IDEA share the same JavaScript plug-in, this issue also applies to the product that you are using. You will continue to observe the described problem until this bug is fixed. Sorry for the inconvenience.

Robert Verdes

WebStorm (at least 6.0.2) supports code navigation with RequireJs if you're defining your modules with the CommonJs wrapper and use the exports and module arguments:

//foo.js
define(function(require, exports, module) {
    //use exports to expose properties for code navigation in other modules
    exports.bar = function() {}
});

Apparently, it works even if the module using it doesn't use the CommonJs wrapper format:

define(['./foo'], function(foo) {
    foo.bar(); //code navigation works here
}

If the other IDEs use the same JavaScript plug-in as CrazyCoder said, it may work on their newer releases as well.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!