Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is jsconfig.json

If I search the same question on the Internet, then I’ll get only links to Visual Studio Code website and some blogs which implements it.

I want to know that is jsconfig.json is specific to Visual Studio Code or javascript/webpack?

What will happen if we deploy the application on AWS, Heroku, etc. Do we have to make change?

like image 247
Rahul Avatar asked Aug 06 '21 04:08

Rahul


People also ask

Where is Tsconfig JSON in VSCode?

json file, located in the . vscode folder at the root of the workspace. You can open the workspace settings. json via the Preferences: Open Workspace Settings (JSON) command from the Command Palette (Ctrl+Shift+P).

How do I start JavaScript code in Visual Studio?

1) Take VSCode 2) Right click on the file in left pane 3) Click "Reveal in explorer" from context menu 4) Right click on the file -> Select "Open with" -> Select "Choose another program" 5) Check box "Always use this app to open . js file" 6) Click "More apps" -> "Look for another app in PC" 7) Navigate to node.

How do I add JavaScript to Visual Studio?

With your project open in Visual Studio, right-click on a folder or your project node in Solution Explorer (right pane), and choose Add > New Item. In the New File dialog box, under the General category, choose the file type that you want to add, such as JavaScript File, and then choose Open.


1 Answers

It's a configuration file to assist your editor's Language Server Protocol (LSP) with the JavaScript usage in your project folder.

While it appears this has originated from Visual Studio Code, any editor using LSP will make use of file jsconfig.json, including Visual Studio Code, Sublime Text and so on.

It's most commonly used to include/exclude folders in your intellisense (which nowadays most editors use LSP), and map aliases in your source code to certain folders.

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "$libs": ["src/libs"],
      "$libs/*": ["src/libs/*"],
    }
  },
  "include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"],
  "exclude": ["node_modules", "**/node_modules", "dist"]
}

This file basically tells the language server to:

baseUrl

Use the . location as the project root (which is where file jsconfig.json) is.

paths

It means $libs in your source code points to /src/libs. This is useful if your editor relies on LSP to locate the files. When you initiate go to file it will go to the right place.

include

It means to include all folders and files ending with those extensions in providing you with file search, code completion.

exclude

It means to exclude everything inside node_modules and dist folder. For instance, you don't want the compiled bundle to appear in search results when you are searching for symbols or variables.

Remarks

In other words, you can consider the jsconfig.json file a bit like the .gitignore file, but for your editor's language server use only.

But keep in mind, if you are going to be using jsconfig.json to map aliases, you would need to do additional configuration to your module bundler, and update your eslint config, that is, if you use ESLint.

For instance, in a Node.js / CommonJS environment, you would need to tell your Node.js what $libs is. There are many ways to do so, but these days people mostly use module-alias.

like image 63
anakha Avatar answered Nov 07 '22 04:11

anakha