Skip to content

Commit

Permalink
feat(vue-tsc): experimentalTscProgramCallbacks (#2217)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk authored Dec 17, 2022
1 parent 70d0d19 commit 4e8b0e4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@
}
},
"markdownDescription": "https://github.com/johnsoncodehk/volar/issues/1969"
},
"experimentalTscProgramCallbacks": {
"type": "array",
"markdownDescription": "https://github.com/johnsoncodehk/volar/pull/2217"
}
}
}
Expand Down
14 changes: 13 additions & 1 deletion vue-language-tools/vue-tsc/src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export function createProgramProxy(

const ctx = {
projectVersion: 0,
options: options,
options,
get languageServiceHost() {
return vueLsHost;
},
};
const vueCompilerOptions = getVueCompilerOptions();
const scripts = new Map<string, {
Expand Down Expand Up @@ -118,6 +121,15 @@ export function createProgramProxy(
options.host.getSourceFile(rootName, ts.ScriptTarget.ESNext);
}

const vueCompilerOptions = program.__vue.languageServiceHost.getVueCompilationSettings();
if (vueCompilerOptions.experimentalTscProgramCallbacks) {
for (const cbPath of vueCompilerOptions.experimentalTscProgramCallbacks) {
const dir = program.__vue.languageServiceHost.getCurrentDirectory();
const cb = require(require.resolve(cbPath, { paths: [dir] }));
cb(program);
}
}

return program;
}

Expand Down

0 comments on commit 4e8b0e4

Please sign in to comment.