tleunen / babel-plugin-module-resolver

Custom module resolver plugin for Babel
MIT License
3.46k stars 205 forks source link

Correct usage of jsconfig.json for VSCode autocompletion/intellisense #372

Closed nnals closed 5 years ago

nnals commented 5 years ago

Hello,

I am a bit confused about what VSCode's jsonfig.json file has to look like for intellisense to work properly.

I have the following babel config:

module.exports = {
  presets: [
    ...
  ],
  plugins: [
    ...
    [
      'module-resolver',
      {
        root: './src',
        alias: {
          src: './src',
        },
      },
    ],
  ],
};

This allows me to import Foo from 'components/foo' instead of e.g. import Foo from '../components/foo'

And I (unsuccessfully) tried the following for jsonfig.json:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "*": ["./src/*"]
    }
  }
}

Could some help me with this?

Thanks a lot! Nicolai

cbdeveloper commented 5 years ago

Here's my jsconfig.json for VSCode:

{
  "compilerOptions": {
      "baseUrl": ".",
      "target": "es6",
      "module": "commonjs",
      "paths": {
        "@components/*": ["./src/components/*"],
        "@constants/*": ["./src/constants/*"],
        "@helpers/*": ["./src/helpers/*"]
      }
  },
  "include": [
    "src/**/*"
  ]
}
nnals commented 5 years ago

intellisense is a bit slow but it works. thank you, @cbdeveloper!

cbdeveloper commented 5 years ago

No problem! I also find it a little bit slow. But works! Even on auto imports.