From e4878a3a74cd15bb40a74ebc0abedfa4b93b25bc Mon Sep 17 00:00:00 2001 From: yoyo930021 Date: Sun, 11 Oct 2020 15:32:17 +0800 Subject: [PATCH 1/3] Pass version in new template sourceFile --- server/src/services/typescriptService/preprocess.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/server/src/services/typescriptService/preprocess.ts b/server/src/services/typescriptService/preprocess.ts index 04ad59b6e4..ce85a2e433 100644 --- a/server/src/services/typescriptService/preprocess.ts +++ b/server/src/services/typescriptService/preprocess.ts @@ -122,6 +122,15 @@ export function createUpdater(tsModule: T_TypeScript, allChildComponentsInfo: Ma true /* setParentNodes: Need this to walk the AST */, tsModule.ScriptKind.JS ); + // Pass version in new template sourceFile + // Don't update program and file every time + // *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 +188,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 +213,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!); } } From a889912fedf4544344640021ef91d364d3ef7dc7 Mon Sep 17 00:00:00 2001 From: yoyo930021 Date: Sun, 11 Oct 2020 15:52:10 +0800 Subject: [PATCH 2/3] CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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) From 53ef21d9540a84bb8b9fb457e6dc5bf064f7de51 Mon Sep 17 00:00:00 2001 From: Pine Wu Date: Fri, 30 Oct 2020 10:30:42 +0800 Subject: [PATCH 3/3] Clarify intent --- server/src/services/typescriptService/preprocess.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/src/services/typescriptService/preprocess.ts b/server/src/services/typescriptService/preprocess.ts index ce85a2e433..1dfe374f2d 100644 --- a/server/src/services/typescriptService/preprocess.ts +++ b/server/src/services/typescriptService/preprocess.ts @@ -122,8 +122,7 @@ export function createUpdater(tsModule: T_TypeScript, allChildComponentsInfo: Ma true /* setParentNodes: Need this to walk the AST */, tsModule.ScriptKind.JS ); - // Pass version in new template sourceFile - // Don't update program and file every time + // 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 = {