| Summary: | Multi-part node require is not being found correctly | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [ECD] Orion | Reporter: | Michael Rennie <Michael_Rennie> | ||||||
| Component: | JS Tools | Assignee: | Michael Rennie <Michael_Rennie> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||
| Severity: | normal | ||||||||
| Priority: | P1 | CC: | curtis.windatt.public, steve_northover | ||||||
| Version: | 13.0 | Flags: | curtis.windatt.public:
review+
steve_northover: review+ |
||||||
| Target Milestone: | 14.0 | ||||||||
| Hardware: | PC | ||||||||
| OS: | Mac OS X | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
|
Description
Michael Rennie
If this is easy/safe etc. we could consider it for Orion 14. If there are performance or other considerations, likely we leave it. If I add a main entry in package.json, would this help? Created attachment 267178 [details]
Example project showing problem
This is a simplified example that shows the problem. It can be imported into orion.eclipse.org or orionhub.org to reproduce.
(In reply to Steve Northover from comment #1) > If this is easy/safe etc. we could consider it for Orion 14. If there are > performance or other considerations, likely we leave it. > > If I add a main entry in package.json, would this help? In this case probably not, simply because the way that the dependency is available on-disk. Created attachment 267200 [details]
Fix
The problem boiled down to:
1. not properly returning the file name in the Tern response
2. not trying to look up the correct file based on the module path
The patch fixes those things and removes an unnecessary file extension check and properly returns a failed read back to Tern (when the lib were looking for cannot be found.
Umm ... safe and good ... ? (In reply to Steve Northover from comment #5) > Umm ... safe and good ... ? Small fix, only targets multi-part requires, and fixes a bug that apparently has always been there. My only concern is that calling _failedRead will now output the 404 to the console when you enter a bogus path. Otherwise the change makes some obvious improvements (deleting duplicate code, actually returning the file) and makes the code safer by removing the _nodeRead recursion. I opened a bug to consider handling require on folders in the future (right now we just append .js to the path). Bug 513402 - Allow node require for folders I'll hold off on +1 until the 404 is addressed. (In reply to Curtis Windatt from comment #7) > I'll hold off on +1 until the 404 is addressed. just a simple update on the read call to: fileclient.read(fileToLoad, false, false, {readIfExists: true}) I'll make the change and push the patch. Pushed fix to: http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=f9e8726e95dc329c0183477859b2890a69372649 Much better +1 for 14.0 |