From 7ea523999a062f14a6e2ed09c49fda860973f2b0 Mon Sep 17 00:00:00 2001 From: Petter Nordholm Date: Sun, 5 May 2019 09:46:07 +0200 Subject: [PATCH] Support for vetur specific ts/jsconfig 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__/*" ] } --- server/src/services/typescriptService/serviceHost.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/server/src/services/typescriptService/serviceHost.ts b/server/src/services/typescriptService/serviceHost.ts index 7564b56253..858c2c343a 100644 --- a/server/src/services/typescriptService/serviceHost.ts +++ b/server/src/services/typescriptService/serviceHost.ts @@ -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,