8000 perf(typescript-plugin): re-implement subscription of component names and props by KazariEX · Pull Request #5329 · vuejs/language-tools · GitHub
[go: up one dir, main page]

Skip to content

perf(typescript-plugin): re-implement subscription of component names and props #5329

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

Closed
wants to merge 11 commits into from
Prev Previous commit
Next Next commit
fix: initialize component names
  • Loading branch information
KazariEX committed Apr 19, 2025
commit f3e650395f539de52b106fa742660002b78ba27d
13 changes: 8 additions & 5 deletions packages/typescript-plugin/lib/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function addVueCommands(
);
}

const data = getComponentInfo(scriptInfo.fileName);
let data = getComponentInfo(scriptInfo.fileName);
const [oldComponentNames, componentProps] = data;
const newComponentNames = getComponentNames.apply(requestContext, [scriptInfo.fileName]) ?? [];

Expand All @@ -98,10 +98,13 @@ export function addVueCommands(
}
}

function getComponentInfo(fileName: string) {
function getComponentInfo(fileName: string, initialize?: boolean) {
let data = componentInfos.get(fileName);
if (!data) {
componentInfos.set(fileName, data = [[], {}]);
componentInfos.set(fileName, data = [
initialize && getComponentNames.apply(getRequestContext(fileName), [fileName]) || [],
{}
]);
}
return data;
}
Expand All @@ -123,11 +126,11 @@ export function addVueCommands(
});
session.addProtocolHandler('vue:getComponentNames', ({ arguments: [fileName] }) => {
return {
response: getComponentInfo(fileName)[0],
response: getComponentInfo(fileName, true)[0],
};
});
session.addProtocolHandler('vue:getComponentProps', ({ arguments: [fileName, tag] }) => {
const [, componentProps] = getComponentInfo(fileName);
const [, componentProps] = getComponentInfo(fileName, true);
let response = componentProps[tag]
?? componentProps[camelize(tag)]
?? componentProps[capitalize(camelize(tag))];
Expand Down
Loading
0