11/* eslint-disable */
22import { existsSync, readdirSync, renameSync, readFileSync } from 'fs';
33import crypto from 'crypto';
4- import { emptyDirSync, ensureFileSync, readJsonSync, removeSync, writeJsonSync } from 'fs-extra';
4+ import { emptyDirSync, ensureFileSync, readJsonSync, removeSync, writeJsonSync, pathExistsSync } from 'fs-extra';
55import { dirname, isAbsolute, join, relative, normalize } from 'path';
66import { sync } from 'resolve';
77
@@ -19523,6 +19523,33 @@ var FormatHost = /** @class */ (function () {
1952319523}());
1952419524var formatHost = new FormatHost();
1952519525
19526+ var NoCache = /** @class */ (function () {
19527+ function NoCache() {
19528+ }
19529+ NoCache.prototype.exists = function (_name) {
19530+ return false;
19531+ };
19532+ NoCache.prototype.path = function (name) {
19533+ return name;
19534+ };
19535+ NoCache.prototype.match = function (_names) {
19536+ return false;
19537+ };
19538+ NoCache.prototype.read = function (_name) {
19539+ return undefined;
19540+ };
19541+ NoCache.prototype.write = function (_name, _data) {
19542+ return;
19543+ };
19544+ NoCache.prototype.touch = function (_name) {
19545+ return;
19546+ };
19547+ NoCache.prototype.roll = function () {
19548+ return;
19549+ };
19550+ return NoCache;
19551+ }());
19552+
1952619553function convertDiagnostic(type, data) {
1952719554 return lodash_7(data, function (diagnostic) {
1952819555 var entry = {
@@ -19540,8 +19567,9 @@ function convertDiagnostic(type, data) {
1954019567 });
1954119568}
1954219569var TsCache = /** @class */ (function () {
19543- function TsCache(host, cache, options, rollupConfig, rootFilenames, context) {
19570+ function TsCache(noCache, host, cache, options, rollupConfig, rootFilenames, context) {
1954419571 var _this = this;
19572+ this.noCache = noCache;
1954519573 this.host = host;
1954619574 this.options = options;
1954719575 this.rollupConfig = rollupConfig;
@@ -19567,8 +19595,10 @@ var TsCache = /** @class */ (function () {
1956719595 this.checkAmbientTypes();
1956819596 }
1956919597 TsCache.prototype.clean = function () {
19570- this.context.info(safe_5("cleaning cache: " + this.cacheDir));
19571- emptyDirSync(this.cacheDir);
19598+ if (pathExistsSync(this.cacheDir)) {
19599+ this.context.info(safe_5("cleaning cache: " + this.cacheDir));
19600+ emptyDirSync(this.cacheDir);
19601+ }
1957219602 this.init();
1957319603 };
1957419604 TsCache.prototype.setDependency = function (importee, importer) {
@@ -19653,10 +19683,18 @@ var TsCache = /** @class */ (function () {
1965319683 return convertedData;
1965419684 };
1965519685 TsCache.prototype.init = function () {
19656- this.codeCache = new RollingCache(this.cacheDir + "/code", true);
19657- this.typesCache = new RollingCache(this.cacheDir + "/types", true);
19658- this.syntacticDiagnosticsCache = new RollingCache(this.cacheDir + "/syntacticDiagnostics", true);
19659- this.semanticDiagnosticsCache = new RollingCache(this.cacheDir + "/semanticDiagnostics", true);
19686+ if (this.noCache) {
19687+ this.codeCache = new NoCache();
19688+ this.typesCache = new NoCache();
19689+ this.syntacticDiagnosticsCache = new NoCache();
19690+ this.semanticDiagnosticsCache = new NoCache();
19691+ }
19692+ else {
19693+ this.codeCache = new RollingCache(this.cacheDir + "/code", true);
19694+ this.typesCache = new RollingCache(this.cacheDir + "/types", true);
19695+ this.syntacticDiagnosticsCache = new RollingCache(this.cacheDir + "/syntacticDiagnostics", true);
19696+ this.semanticDiagnosticsCache = new RollingCache(this.cacheDir + "/semanticDiagnostics", true);
19697+ }
1966019698 };
1966119699 TsCache.prototype.markAsDirty = function (id) {
1966219700 this.dependencyTree.setNode(id, { dirty: true });
@@ -19824,7 +19862,7 @@ function typescript(options) {
1982419862 var _cache;
1982519863 var cache = function () {
1982619864 if (!_cache)
19827- _cache = new TsCache(servicesHost, pluginOptions.cacheRoot, parsedConfig.options, rollupOptions, parsedConfig.fileNames, context);
19865+ _cache = new TsCache(pluginOptions.clean, servicesHost, pluginOptions.cacheRoot, parsedConfig.options, rollupOptions, parsedConfig.fileNames, context);
1982819866 return _cache;
1982919867 };
1983019868 var pluginOptions = __assign({}, options);
0 commit comments