LT-TernJS icon indicating copy to clipboard operation
LT-TernJS copied to clipboard

Mixed CommonJS and AMD project cause crash

Open mortalapeman opened this issue 10 years ago • 5 comments

Original discussion can be found at issue #9.

mortalapeman avatar Apr 15 '14 15:04 mortalapeman

@joshuafcole Can you see if you are still having issues with the 0.1.6 release?

mortalapeman avatar May 03 '14 03:05 mortalapeman

Sorry for the delay, was on vacation. I've tested it and gotten an error when trying to use tern in the CommonJS portion of the project. The AMD portion does not crash but doesn't seem to pick up all dependencies either. It figured out underscore, for example, but not dust.

The AMD file in question is here: http://pastebin.com/qi1Qe6Q1 The relevant portion of the CommonJS file is here: http://pastebin.com/DWgfvtQ8 My user.behaviors: http://pastebin.com/gs4Fd97E

The error on use in CommonJS:

"Invalid behavior: :lt.objs.clients/handle-message" TypeError: Cannot call method 'replace' of undefined at clojure.string.replace (file:///Users/jcole/repos/external/LightTable/deploy/core/node_modules/lighttable/bootstrap.js:16923:14) at format_doc (/Users/jcole/Library/Application%20Support/LightTable/plugins/TernJS/ternjs_compiled.js:714:265) at b (file:///Users/jcole/repos/external/LightTable/deploy/core/node_modules/lighttable/bootstrap.js:8071:176) at a (file:///Users/jcole/repos/external/LightTable/deploy/core/node_modules/lighttable/bootstrap.js:8111:18) at Function.__BEH__javascript_format_doc (/Users/jcole/Library/Application%20Support/LightTable/plugins/TernJS/ternjs_compiled.js:716:124) at d (file:///Users/jcole/repos/external/LightTable/deploy/core/node_modules/lighttable/bootstrap.js:6200:163) at a (file:///Users/jcole/repos/external/LightTable/deploy/core/node_modules/lighttable/bootstrap.js:6238:18) at eval (file:///Users/jcole/repos/external/LightTable/deploy/core/node_modules/lighttable/bootstrap.js:20593:73) at c (file:///Users/jcole/repos/external/LightTable/deploy/core/node_modules/lighttable/bootstrap.js:2970:15) at a (file:///Users/jcole/repos/external/LightTable/deploy/core/node_modules/lighttable/bootstrap.js:2996:18)

joshuafcole avatar May 05 '14 17:05 joshuafcole

Your user behavior doesn't appear to be setup to handle AMD. Try setting your user behaviors to:

{:+ {:tern.config [(:lt.plugins.tern/plugin :node true)
                          (:lt.plugins.tern/plugin :requirejs {:baseURL "/home/path/to/project/dir"})
                          :lt.plugins.tern/lazy-loading]}}

Let me know if you still have problems afterwards. The next thing on my list is getting the tern plugin setup to support multiple projects with multiple servers. That way you can have a workspace with AMD + node and you won't be getting completions for the browser in your node project.

Are you getting that error when asking for docs?

mortalapeman avatar May 06 '14 01:05 mortalapeman

Sorry for the delay, my email inbox is well past out of control. Yes, I was getting it in response to querying docs. I wouldn't expect an error though, and I would expect some feedback that no docs were found / provided. In the same NodeJS context, I also can't jump to definition either. Actually, in some cases I can pull in docs but can't jump to definition. It looks as though the definition is wrong though in this case. It's claiming "this.emit" is events.EventEmitter.prototype.emit, when in fact it's actually coming from the async-cancelable-events module.

joshuafcole avatar May 13 '14 17:05 joshuafcole

I'm getting that problem all over the place actually. It thinks my mongodb-native db object is an instance of crypto.Hash.

It may be that I'm just expecting too much from Tern in this context. I had assumed that it would function somewhat like TypeScript in that type information would flow through the system rather than being limited to a single file. Guessing randomly seems malicious though, particularly when the signature of the guess doesn't remotely match the signature of the invocation.

joshuafcole avatar May 13 '14 17:05 joshuafcole