UNPKG

vue-vine-tsc

Version:

Command line typescript checker for Vue Vine

60 lines (57 loc) 2.66 kB
//#region rolldown:runtime var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { key = keys[i]; if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: ((k) => from[k]).bind(null, key), enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); //#endregion const node_path = __toESM(require("node:path")); const __volar_typescript_lib_quickstart_runTsc = __toESM(require("@volar/typescript/lib/quickstart/runTsc")); const __vue_vine_language_service = __toESM(require("@vue-vine/language-service")); const __vue_language_core = __toESM(require("@vue/language-core")); //#region src/index.ts const windowsPathReg = /\\/g; function run() { const tscSdk = require.resolve("typescript/lib/tsc"); const main = () => { (0, __volar_typescript_lib_quickstart_runTsc.runTsc)(tscSdk, [".vine.ts", ".vue"], (ts, runTscOptions) => { const languagePlugins = []; const { configFilePath } = runTscOptions.options; let vueOptions; if (typeof configFilePath === "string") { vueOptions = (0, __vue_language_core.createParsedCommandLine)(ts, ts.sys, configFilePath.replace(windowsPathReg, "/"), true).vueOptions; const globalTypesFilePath = (0, __vue_vine_language_service.setupGlobalTypes)(node_path.posix.dirname(configFilePath.replace(windowsPathReg, "/")), vueOptions, ts.sys); if (globalTypesFilePath) vueOptions.__setupedGlobalTypes = globalTypesFilePath; } else vueOptions = (0, __vue_language_core.getDefaultCompilerOptions)(void 0, void 0, true); languagePlugins.push((0, __vue_language_core.createVueLanguagePlugin)(ts, runTscOptions.options, vueOptions, (id) => id)); languagePlugins.push((0, __vue_vine_language_service.createVueVineLanguagePlugin)(ts, { compilerOptions: runTscOptions.options, vueCompilerOptions: vueOptions, target: "tsc" })); return { languagePlugins }; }); }; try { main(); } catch (err) { console.error("[vue-vine-tsc]", err); } } //#endregion exports.run = run;