tern icon indicating copy to clipboard operation
tern copied to clipboard

Webpack module completion not working for top level directories

Open hoschi opened this issue 8 years ago • 5 comments
trafficstars

I don't get candidates for top level source directories, only one level deeper when trying to write an import statement in 'MyComponent.js': import foo from 'servi| gives nothing import foo from 'services/|' gives the right candidate 'services/funcHelper'

this is my environment:

directory structure:

src/services/funcHelper.js
src/components/MyComponent.js`

tern config:

{
    "plugins":{
        "modules":{},
        "es_modules":{},
        "webpack":{
            "configPath":"./.webpack.tern.js"
        },
        "jsx":{}
    },
    "libs": [],
    "ecmaVersion": 6
}

.webpack.tern.js:

var path = require('path')
module.exports = {
    resolve: {
      extensions: ['', '.js', '.json'],
      root: [
        path.resolve(__dirname, 'src'),
        path.resolve(__dirname, 'node_modules'),
      ],
    },
}

tern_for_vim is commit d81658d3 tern version tried from tern_for_vim and latest 0.21.0 without a change

hoschi avatar Mar 04 '17 09:03 hoschi

I also noticed that only candidades show up when the cursor is right behind the trailing slash: import foo from 'services/|' but not when I typed something behind the slash before the completion started: import foo from 'services/fu|

hoschi avatar Mar 04 '17 10:03 hoschi

As far as I know, tern is not used for path complete, so the complete of import foo from 'servi| would never be done by tern.

For the complete of import foo from 'services/|' should be provided by your complete plugin, for example deoplete.nvim

chemzqm avatar Mar 04 '17 10:03 chemzqm

It gets completed by webpack plugin of tern. Hence the resolve config.

Qiming zhao [email protected] schrieb am Sa., 4. März 2017, 11:49:

As far as I know, tern is not used for path complete, so the complete of import foo from 'servi| would never be done by tern.

For the complete of import foo from 'services/|' should be provided by your complete plugin, for example deoplete.nvim

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ternjs/tern/issues/893#issuecomment-284143824, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJ9OHVECDVqzSt92WtsiqFNuWxBevRiks5riUGvgaJpZM4MTCX5 .

hoschi avatar Mar 04 '17 13:03 hoschi

@hoschi you're right, didn't notice that tern could provide this kind of path complete before

chemzqm avatar Mar 04 '17 15:03 chemzqm

We also use src as a root path but i'm unable to get this to work having tried a bunch of .tern-project config.

s-taylor avatar Jun 05 '18 00:06 s-taylor