UNPKG

vite-typescript-plugin

Version:

A Vite plugin for seamless integration between Vite and Typescript.

28 lines (27 loc) 1.2 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getCanonicalFileName = void 0; const typescript_1 = __importDefault(require("typescript")); const path_1 = __importDefault(require("path")); const fileNameLowerCaseRegExp = /[^\u0130\u0131\u00DFa-z0-9\\/:\-_\. ]+/g, toLowerCase = (fileName) => fileName.toLowerCase(); const getFileName = (typescript_1.default.sys.useCaseSensitiveFileNames ? (fileName) => fileName : (fileName) => { return fileNameLowerCaseRegExp.test(fileName) ? fileName.replace(fileNameLowerCaseRegExp, toLowerCase) : fileName; }); function getCanonicalFileName(fileName) { const newFileName = getFileName(fileName); const extname = path_1.default.extname(newFileName); if (extname.length !== 0) { if (extname in this.extensionsSupport) { return newFileName + (this.extensionsSupport[extname].extension); } } return newFileName; } exports.getCanonicalFileName = getCanonicalFileName;