vuejs / language-tools

⚡ High-performance Vue language tooling based-on Volar.js
https://marketplace.visualstudio.com/items?itemName=Vue.volar
MIT License
5.75k stars 385 forks source link

Alternatives to the old createProgram? #4618

Open ilteoood opened 1 month ago

ilteoood commented 1 month ago

Vue - Official extension or vue-tsc version

2.0.0

VSCode version

*

Vue version

*

TypeScript version

=5.0.0

System Info

No response

Steps to reproduce

Try to use the createProgram API, available in version 1.

What is expected?

On module federation, we used to use the createProgram API of vue-tsc in order to create a TypeScript program to generate the federated modules: https://github.com/module-federation/core/blob/main/packages/native-federation-typescript/src/lib/typeScriptCompiler.ts#L108. As I can see in this PR: https://github.com/vuejs/language-tools/pull/3795, the API has been removed without a clear alternative to invoke the compiler programmatically.

I don't want to invoke the CLI to do basic operations I was doing before without any issue. Is there an alternative route I can take, or is there a chance to bring back the old API?

What is actually happening?

Can't programmatically create a vue-tsc program anymore

Link to minimal reproduction

No response

Any additional comments?

No response

so1ve commented 1 month ago

Could you please check: https://github.com/fi3ework/vite-plugin-checker/pull/327, https://github.com/fi3ework/vite-plugin-checker/blob/main/packages/vite-plugin-checker/src/checkers/vueTsc/main.ts? I thought they might be helpful.

ilteoood commented 1 month ago

@so1ve if I got it correctly, the function that should cover my scenario is the getLanguagePlugins, isn't it?

so1ve commented 1 month ago

Perhaps no? I'm not familiar with volar.js but I guess you may use proxyCreateProgram and getLanguagePlugins together?

Sysix commented 1 month ago

I have the same problem. I have a rule for betterer similar to its native typescript rule

prepareVueTsc doesn't feel right. When vue-tsc is changing we need maybe update the script again. Would love to see createProgram back.