Require and go to definition


#1

I have two files:
yoba1.js:
var yoba2 = require("./yoba2")

function yoba(a, b) {
    return a + b;
}

function foo(x) {
    return x;
}

yoba(foo(yoba(1, 2)), 3)
yoba2.bar()

and yoba2.js:
function bar(a, b) {
var c = [];
return a * b;
}

.tern-project:
{
“libs”: [
“browser”,
“jquery”
],
“loadEagerly”: [
"*.js",
],
“plugins”: {
“requirejs”: {
“baseURL”: “./”,
“paths”: {}
}
}
}

And I got {} for “definition” request. What is proper way to deal with multiply files?


#2

requirejs is for asynchronous modules, you want the node plugin if you’re going to use require()


#3

Thanks, I change .tern-project to:
{
“libs”: [
“browser”,
“jquery”
],
“loadEagerly”: [
"*.js",
],
“plugins”: {
“node”: {}
}
}

Still no success. I have competitions for yoba1.js in yoba1.js, have competitions for yoba2.js in yoba2.js. But no cross competitions.


#4

You’re not exporting anything. If you try to run that in a CommonJS environment it won’t work either. I think it would help if you learned about the way module systems work first.


#5

Oh, right you are. My bad. I got cross references working with proper .tern-project file and proper tern starting directory. But… is there way to tell tern which plugins to use and all other options without .tern-project file?


#6

You can change your local defaults by putting a .tern-config file (using the same JSON format) in your home directory.