capaj / vscode-exports-autocomplete

finds javascript ES6 exports in your project and autocompletes them when writing javascript statements
MIT License
18 stars 6 forks source link

add project specific moduleResolverRoot option #22

Open capaj opened 7 years ago

capaj commented 7 years ago

some people use stuff like babel-plugin-module-resolver with a root set to some dir in the project and they prefer their paths to not start with ./. For these people, we'll add this options so that you can use this plugin without manually editing the import statement.

cheapsteak commented 7 years ago

A few lines of mokeypatch code that may help with this PR

In exporters-completion-provider.js add these lines right before let importToken = ex.name

          const importPath = fileName.includes('@ncigdc')
            ? fileName.substr(fileName.indexOf('@ncigdc'), fileName.lastIndexOf('.'))
            : relPath;

Replace subsequent references to relPath with importPath

An example of our file path : "/Users/cheapsteak/gdc/portal-ui/modules/node_modules/@ncigdc/components/Annotation.js"

Replacing '@ncigdc' with the moduleResolverRoot variable may satisfy this issue more generally