Skip to content

Commit

Permalink
Merge pull request #1270 from vuejs/scriptFileNames-perf
Browse files Browse the repository at this point in the history
Try approach mentioned in #1051
  • Loading branch information
octref authored May 2, 2019
2 parents 823b3e4 + bd4105e commit 598a756
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions server/src/services/typescriptService/serviceHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ export function getServiceHost(

const parsedConfig = getParsedConfig(tsModule, workspacePath);
const files = parsedConfig.fileNames;
const scriptFileNameSet = new Set(files);

const isOldVersion = inferIsOldVersion(tsModule, workspacePath);
const compilerOptions = {
...getDefaultCompilerOptions(tsModule),
Expand Down Expand Up @@ -104,9 +106,10 @@ export function getServiceHost(
// When file is not in language service, add it
if (!scriptDocs.has(fileFsPath)) {
if (fileFsPath.endsWith('.vue') || fileFsPath.endsWith('.vue.template')) {
files.push(filePath);
scriptFileNameSet.add(filePath);
}
}

if (isVirtualVueTemplateFile(fileFsPath)) {
scriptDocs.set(fileFsPath, doc);
versions.set(fileFsPath, (versions.get(fileFsPath) || 0) + 1);
Expand Down Expand Up @@ -138,7 +141,7 @@ export function getServiceHost(
function createLanguageServiceHost(options: ts.CompilerOptions): ts.LanguageServiceHost {
return {
getCompilationSettings: () => options,
getScriptFileNames: () => files,
getScriptFileNames: () => Array.from(scriptFileNameSet),
getScriptVersion(fileName) {
if (fileName === bridge.fileName) {
return '0';
Expand Down

0 comments on commit 598a756

Please sign in to comment.