ternjs / tern_for_sublime

Sublime Text package adding Tern support
MIT License
803 stars 54 forks source link

Requirejs plugin not working #43

Closed flea89 closed 10 years ago

flea89 commented 10 years ago

I'm trying to setup a simple project to test the plugin features, but I'm facing problems to see it working.

I have a simple workspace structure:

.
├── .tern-project
├── main.js
├── myModule.js

My tern configuration is: .tern-project

{
  "libs": [
    "browser",
    "jquery"
  ],
  "plugins": {
    "requirejs": {
      "baseURL": ".",
      "paths": {}
    }
  }
}

myModule.js

define([], function(){
    return {
        myNumber: 1,
        myString: 'foo'
    };
});

main.js

define(['myModule'],function(myModule){
    myModule.
});

I'm not getting hints from tern, I'm not sure if I'm doing something wrong or this could be a bug.

Thanks

flea89 commented 10 years ago

Just realized the problem, in main.js the code was actually

define(['module'],function(module){
    module.
});

and the plugin was probably getting confuse by module object for requirejs commonjs module format.

marijnh commented 10 years ago

Yes, "exports", "module" and "require" are hard-coded to return the built-in CommonJS compatibility values.

Does that solve your problem?

flea89 commented 10 years ago

Thanks @marijnh, yes it solved the problem, I'm now trying to set it up for a bigger projects but it's not working. Probably I'm doing something wrong though. I'll try harder :)

marijnh commented 10 years ago

Great. Open another issue when you have a specific problem.