Skip to content

Reverse order of resolving #927

@joeheyming

Description

@joeheyming

First of all, I really really like tern. It really solves a lot of problems for me.

Basically, I have a webpack project where I have multiple javascript modules.
/project/
/project/externalModule/
/project/externalModule2/
/project/mainModule

Due to reasons outside of my control, a developer set up the project such that mainModule is built with webpack, but the module has externalModule1 and 2 installed under /project/mainModule/node_modules

I set up a dummy webpack config as follows:
{
alias: [
externalModule1: path.resolve('/project/externalModule1')
externalModule2: path.resolve('/project/externalModule2')
]
}

The issue I'm having is that the "Module" plugin is resolving before the webpack plugin:
https://github.com/ternjs/tern/blob/master/plugin/modules.js#L55
because the order of resolvers is:
modules => es_modules => webpack

I believe the order should be reversed:
webpack => es_modules => modules

I did a quick change to the plugin:
https://github.com/ternjs/tern/blob/master/plugin/webpack.js#L79
I changed push to unshift.

When I did this, and execute M-. in emacs, it goes to the correct alias I defined in the webpack config.js. Whereas before, it would to to /project/mainModule/node_modules/externalModule1/someFile.js

But I want it to resolve to
/project/externalModule1/someFile.js

What are the implications of changing the order of resolving?
Can we configure .tern_project to reverse the ordering?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions