'Visual Studio Code - how to Go To Definition / open file in JavaScript import statements?

I have a html file with JavaScript module in it, like so:

<script type="module">

    import * as LOADER from './path/loader.js'

    import { add } from '/path/ui.js'

  </script>

I run a server at localhost, so I have a local folder set as a root (under Win10) and the file works perfectly in the browser.

When I open this file in VS Code, it doesn't understand paths mentioned in import statements, relative or absolute, I can't use Go To Definition or Peek or open imported .js files.

Is it possible to make VS Code work with import statements?

I created jsconfig.json file in the same folder as the html file:

{
  "compilerOptions": {
    "module": "commonjs",
    "baseUrl": ".",
    "paths": {
      "/*": ["./*"]
    }
  },
  "include": ["/path/*"]
}

but it doesn't make any difference.

EDIT:

the paths are not underlined like links in href attributes for example. I know it should work but it doesn't.

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source