Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass version in new template sourceFile for ts perf #2374

Merged
merged 3 commits into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 10 additions & 2 deletions server/src/services/typescriptService/preprocess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand All @@ -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!);
}
}

Expand Down