tern
tern copied to clipboard
Using `es_modules` and `node` plugin together breaks jump to definition in some cases
trafficstars
Hi,
When trying to enable both es_modules and node plugin together, jump to definition query wont work, but completions requests work if a file is imported without specifying .js extension as described below.
We have the following tern init code in Brackets:
ternOptions = {
defs: env,
async: true,
getFile: getFile,
plugins: {
commonjs: true,
requirejs: {},
angular: true,
complete_strings: true,
doc_comment: true,
doc_comments: true,
es_modules: true,
node: true,
node_resolve: true
}
};
Jump to definition fails in ternjs demo site as well https://ternjs.net/doc/demo/index.html#ES6 if the init for the demo includes node: true, along with the current tern init options in demo.
The issue can be recreated with three files below, fail.js, pass.js and list.js with contents below:
// fail.js
import {test} from "./list"
// pass.js
import {test} from "./list.js"
// list.js
export function test(){}
The problem:
- Jump to
definitiontern query will not work if we try to trigger it from line1:testinfail.js, but it will work frompass.js. - However,
completionsrequests pass for both cases to get code hints. - The problem is not present if i only use
es_modulesplugin and notnodeplugin.
expected result
- Jump to
definitionquery andcompletionsquery should behave the same. But having completions and definitions error tolerant would help with edits. - Should behave consistently with both
es_modulesplugin andnodeplugin enabled.
Background reading done
https://stackoverflow.com/questions/55251956/how-does-javascript-import-find-the-module-without-an-extension
Thanks, Arun.