flow/flow-for-vscode

I'm used babel-plugin-module-resolver cannot resolve module in vscode.

viweei opened this issue · 4 comments

flow with babel-plugin-module-resolver is work well in shell,but plugin of flow-language-support in vscode cannot resolve module.

it's screenshot in vscode
image

but nothing error in shell.
image

I were changed "@/store" to "./store", it does worked well.
image

here are config file of .babelrc and .flowconfig

.babelrc

{
  "presets": ["@babel/preset-flow", "@babel/preset-env"],
  "plugins": [
    "@babel/plugin-transform-runtime",
    [
      "module-resolver",
      {
        "root": ["src"],
        "extensions": [".js", ".jsx"],
        "alias": {
          "@": "./src"
        }
      }
    ]
  ]
}

.flowcofnig

[ignore]

[include]

[libs]
flow-typed/

[lints]

[options]
module.system.node.resolve_dirname=node_modules
module.system.node.resolve_dirname=src

[strict]
noppa commented

This a problem in your Flow configuration and not an issue in the VSCode extension. If you run flow check on the command line, I bet that doesn't work correctly either (edit: didn't notice you already had run it).

In this case, you need something like

module.name_mapper='^@/\(.*\)$' -> '<PROJECT_ROOT>/src/\1'

in the flowconfig [options]. See name_mapper in the options docs.

mroch commented

it looks like yarn flow ./src should've checked all the files, since there's no lazy mode. so then my question is why the CLI missed it...

unless the squiggle in vscode is actually from the built-in typescript/javascript language support?

@noppa Yes~ I had appended

module.name_mapper='^@/(.*)$' -> '<PROJECT_ROOT>/src/\1'

to section end of options and restart vscode then it worked. Thanks~ 👍

@mroch Are you mean javascript.validate.enable and typescript.validate.enable options ? I already set them value were false, but it had error yet.