提交学习笔记专用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.7 KiB

  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.run = run;
  4. const runTsc_1 = require("@volar/typescript/lib/quickstart/runTsc");
  5. const core = require("@vue/language-core");
  6. const windowsPathReg = /\\/g;
  7. function run(tscPath = require.resolve('typescript/lib/tsc')) {
  8. let runExtensions = ['.vue'];
  9. let extensionsChangedException;
  10. const main = () => (0, runTsc_1.runTsc)(tscPath, runExtensions, (ts, options) => {
  11. const { configFilePath } = options.options;
  12. const vueOptions = typeof configFilePath === 'string'
  13. ? core.createParsedCommandLine(ts, ts.sys, configFilePath.replace(windowsPathReg, '/')).vueOptions
  14. : core.createParsedCommandLineByJson(ts, ts.sys, (options.host ?? ts.sys).getCurrentDirectory(), {})
  15. .vueOptions;
  16. vueOptions.globalTypesPath = core.createGlobalTypesWriter(vueOptions, ts.sys.writeFile);
  17. const allExtensions = core.getAllExtensions(vueOptions);
  18. if (runExtensions.length === allExtensions.length
  19. && runExtensions.every(ext => allExtensions.includes(ext))) {
  20. const vueLanguagePlugin = core.createVueLanguagePlugin(ts, options.options, vueOptions, id => id);
  21. return { languagePlugins: [vueLanguagePlugin] };
  22. }
  23. else {
  24. runExtensions = allExtensions;
  25. throw extensionsChangedException = new Error('extensions changed');
  26. }
  27. });
  28. try {
  29. return main();
  30. }
  31. catch (err) {
  32. if (err === extensionsChangedException) {
  33. return main();
  34. }
  35. else {
  36. throw err;
  37. }
  38. }
  39. }
  40. //# sourceMappingURL=index.js.map