diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cf6edf6c7..45078094ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - 🙌 Stop computing outdated diagnostics with CancellationToken. Thanks to contribution from [@yoyo930021](https://github.com/yoyo930021). #1263 and #2332. - 🙌 Fix error when optional camel-cased props are missing. Thanks to contribution from [@yoyo930021](https://github.com/yoyo930021). #2314 and #2342. - 🙌 Fix Vetur formatting not working. Thanks to contribution from [@yoyo930021](https://github.com/yoyo930021). #2388 and #2389. +- 🙌 Improve ts perf when `vetur.experimental.templateInterpolationService: true`. Thanks to contribution from [@yoyo930021](https://github.com/yoyo930021). #2192 and #2374. ### 0.28.0 | 2020-09-23 | [VSIX](https://marketplace.visualstudio.com/_apis/public/gallery/publishers/octref/vsextensions/vetur/0.28.0/vspackage) diff --git a/server/src/services/typescriptService/preprocess.ts b/server/src/services/typescriptService/preprocess.ts index 04ad59b6e4..1dfe374f2d 100644 --- a/server/src/services/typescriptService/preprocess.ts +++ b/server/src/services/typescriptService/preprocess.ts @@ -122,6 +122,14 @@ export function createUpdater(tsModule: T_TypeScript, allChildComponentsInfo: Ma true /* setParentNodes: Need this to walk the AST */, tsModule.ScriptKind.JS ); + // Assign version to the new template sourceFile to avoid re-processing + // *internal* property + (newSourceFile as any).version = (sourceFile as any).version; + (newSourceFile as any).scriptSnapshot = { + getText: (start: number, end: number) => newText.substring(start, end), + getLength: () => newText.length, + getChangeRange: () => void 0 + }; const templateFsPath = URI.file(vueTemplateFileName).fsPath; const sourceMapNodes = generateSourceMap(tsModule, sourceFile, newSourceFile); @@ -179,7 +187,7 @@ function modifyVueScript(tsModule: T_TypeScript, sourceFile: ts.SourceFile): voi st => st.kind === tsModule.SyntaxKind.ExportAssignment && (st as ts.ExportAssignment).expression.kind === tsModule.SyntaxKind.ObjectLiteralExpression - ); + ) as ts.ExportAssignment; if (exportDefaultObject) { // 1. add `import Vue from 'vue' // (the span of the inserted statement must be (0,0) to avoid overlapping existing statements) @@ -204,7 +212,7 @@ function modifyVueScript(tsModule: T_TypeScript, sourceFile: ts.SourceFile): voi end: objectLiteral.pos + 1 }); (exportDefaultObject as any).expression = setObjPos(tsModule.createCall(vue, undefined, [objectLiteral])); - setObjPos(((exportDefaultObject as ts.ExportAssignment).expression as ts.CallExpression).arguments!); + setObjPos((exportDefaultObject.expression as ts.CallExpression).arguments!); } }