question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Q: How to support vscode resolution?

See original GitHub issue

https://github.com/Microsoft/vscode/issues/14907

A jsconfig.json won’t work for me, any idea?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:2
  • Comments:18 (4 by maintainers)

github_iconTop GitHub Comments

21reactions
TheRealPSVcommented, Apr 1, 2020

Simple way to do this with a jsconfig.json file:

In your package.json:

{
...
    "_moduleAliases": {
        "@root": ".",
        "@handlers": "./js/handlers",
        "@utils": "./js/utils"
    },
...
}

In jsconfig.json:

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es6",
        "baseUrl": "./",
        "paths": {
            "@root/*": ["./*"],
            "@handlers/*": ["./js/handlers/*"],
            "@utils/*": ["./js/utils/*"]
        }
    },
    "exclude": ["node_modules", "**/node_modules/*"]
}

Basically, you can add the baseUrl as your local path, and copy over your aliases into the paths section. For each alias, you have to add /* to the end of the alias, and turn the path you’re aliasing into an array containing that path, then add /* to the end of it as well.

It’s a little extra work every time you want to add an alias, but it works really well, no extra extension required, and I’m using it now.

If there were a way to make this happen automatically (update the paths value when you update the aliases in package.json), that’d be fantastic.

17reactions
Rushcommented, Jun 9, 2018

Hey y’all. I built an alternative. https://www.npmjs.com/package/link-module-alias

I’m using it currently in a project alongside module-alias but we may switch fully to link-module-alias if no issues are found.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Accessibility in Visual Studio Code
Make sure to have the setting "editor.accessibilitySupport": "on" in VS Code. You can do this using settings, or by running the Show Accessibility...
Read more >
Visual Studio Code Frequently Asked Questions
You can find the VS Code version information in the About dialog box. On macOS, go to Code > About Visual Studio Code....
Read more >
User and Workspace Settings - Visual Studio Code
On Windows/Linux - File > Preferences > Settings; On macOS - Code > Preferences > Settings. You can also open the Settings editor...
Read more >
Visual Studio Code Tips and Tricks
If you forget a keyboard shortcut, use the Command Palette to help you out. ... Use the actions in the editor toolbar to...
Read more >
Settings Sync in Visual Studio Code
... or remote or manually resolve the changes in your local settings file and ... VS Code Settings Sync supports signing in with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found