UNPKG

vite-typescript-plugin

Version:

A Vite plugin for seamless integration between Vite and Typescript.

24 lines (23 loc) 1.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.emitFileIfChanged = void 0; function emitFileIfChanged(fileName, code) { const currentValue = this.fileCache.get(fileName); if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.emitFileValue) !== undefined) { const preCode = currentValue.code; currentValue.sourceFile = (currentValue.modules = (currentValue.code = undefined)); const newCode = code || (code = this.readFile(fileName)); if (preCode == newCode) { return currentValue.emitFileValue; } } this.fileCache.delete(fileName); const cacheFileDetails = this.getCacheFileDetails(fileName); cacheFileDetails.code = code; if (currentValue === undefined) { this.rootNames = [...new Set([...this.rootNames, fileName])]; } this.createProgram(); return cacheFileDetails.emitFileValue = this.emitFileCode(fileName); } exports.emitFileIfChanged = emitFileIfChanged;