Skip to content

Commit

Permalink
Support for vetur specific ts/jsconfig
Browse files Browse the repository at this point in the history
This commit adds support for a vetur specific tsconfig/jsconfig.

To improve performance on vetur on vue files, the number of files
being processed needs to be minimized. For instance, test.ts files
and mocks can be excluded when editing vue files since these files
should never be accessed by production code.

To use this feature, just place an overriden config files at the
same place as the original config file. The file should have the
suffix vetur, i.e. vetur-tsconfig.json. By using the extends
parameter, the original config file can be included to avoid
duplicate configuration:

{
  "extends": "./tsconfig",
  "exclude": [
    "**/*.test.ts",
    "**/__mocks__/*"
  ]
}
  • Loading branch information
petternordholm committed Sep 13, 2019
1 parent 3ce5fab commit 7ea5239
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions server/src/services/typescriptService/serviceHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,15 @@ function inferIsUsingOldVueVersion(tsModule: T_TypeScript, workspacePath: string
}

function getParsedConfig(tsModule: T_TypeScript, workspacePath: string) {
const configFilename =
tsModule.findConfigFile(workspacePath, tsModule.sys.fileExists, 'tsconfig.json') ||
tsModule.findConfigFile(workspacePath, tsModule.sys.fileExists, 'jsconfig.json');
const configJson = (configFilename && tsModule.readConfigFile(configFilename, tsModule.sys.readFile).config) || {
const defaultConfig = {
exclude: defaultIgnorePatterns(tsModule, workspacePath)
};
const configFilenames = ['vetur-tsconfig.json','vetur-jsconfig.json', 'tsconfig.json','jsconfig.json'];

const configFilename = configFilenames.map(filename => tsModule.findConfigFile(workspacePath, tsModule.sys.fileExists, filename)).find(foundFile => !!foundFile);
logger.logDebug(configFilename ? `Using configuration file ${configFilename}` : 'Using default configuration');
const configJson = configFilename ? tsModule.readConfigFile(configFilename, tsModule.sys.readFile).config : defaultConfig;

// existingOptions should be empty since it always takes priority
return tsModule.parseJsonConfigFileContent(
configJson,
Expand Down

0 comments on commit 7ea5239

Please sign in to comment.