mirror of
https://github.com/ezolenko/rollup-plugin-typescript2.git
synced 2025-12-08 19:06:16 +00:00
- saner cache cleaning, not hashing configs if cache is not used
This commit is contained in:
parent
829bd0adb2
commit
4e3a14f466
54
dist/rollup-plugin-typescript2.cjs.js
vendored
54
dist/rollup-plugin-typescript2.cjs.js
vendored
@ -19716,23 +19716,27 @@ function convertDiagnostic(type, data) {
|
||||
});
|
||||
}
|
||||
class TsCache {
|
||||
constructor(noCache, hashIgnoreUnknown, host, cache, options, rollupConfig, rootFilenames, context) {
|
||||
constructor(noCache, hashIgnoreUnknown, host, cacheRoot, options, rollupConfig, rootFilenames, context) {
|
||||
this.noCache = noCache;
|
||||
this.host = host;
|
||||
this.cacheRoot = cacheRoot;
|
||||
this.options = options;
|
||||
this.rollupConfig = rollupConfig;
|
||||
this.context = context;
|
||||
this.cacheVersion = "7";
|
||||
this.cacheVersion = "8";
|
||||
this.cachePrefix = "rpt2_";
|
||||
this.ambientTypesDirty = false;
|
||||
this.hashOptions = { algorithm: "sha1", ignoreUnknown: false };
|
||||
this.hashOptions.ignoreUnknown = hashIgnoreUnknown;
|
||||
this.cacheDir = `${cache}/${objectHash_1({
|
||||
version: this.cacheVersion,
|
||||
rootFilenames,
|
||||
options: this.options,
|
||||
rollupConfig: this.rollupConfig,
|
||||
tsVersion: tsModule.version,
|
||||
}, this.hashOptions)}`;
|
||||
if (!noCache) {
|
||||
this.cacheDir = `${this.cacheRoot}/${this.cachePrefix}${objectHash_1({
|
||||
version: this.cacheVersion,
|
||||
rootFilenames,
|
||||
options: this.options,
|
||||
rollupConfig: this.rollupConfig,
|
||||
tsVersion: tsModule.version,
|
||||
}, this.hashOptions)}`;
|
||||
}
|
||||
this.dependencyTree = new graphlib_1({ directed: true });
|
||||
this.dependencyTree.setDefaultNodeLabel((_node) => ({ dirty: false }));
|
||||
const automaticTypes = lodash_7(tsModule.getAutomaticTypeDirectiveNames(options, tsModule.sys), (entry) => tsModule.resolveTypeReferenceDirective(entry, undefined, options, tsModule.sys))
|
||||
@ -19745,9 +19749,18 @@ class TsCache {
|
||||
this.checkAmbientTypes();
|
||||
}
|
||||
clean() {
|
||||
if (fsExtra.pathExistsSync(this.cacheDir)) {
|
||||
this.context.info(safe_5(`cleaning cache: ${this.cacheDir}`));
|
||||
fsExtra.emptyDirSync(this.cacheDir);
|
||||
if (fsExtra.pathExistsSync(this.cacheRoot)) {
|
||||
const entries = fsExtra.readdirSync(this.cacheRoot);
|
||||
entries.forEach((e) => {
|
||||
const dir = `${this.cacheRoot}/${e}`;
|
||||
if (e.startsWith(this.cachePrefix) && fsExtra.statSync(dir).isDirectory) {
|
||||
this.context.info(safe_5(`cleaning cache: ${dir}`));
|
||||
fsExtra.emptyDirSync(`${dir}`);
|
||||
fsExtra.removeSync(`${dir}`);
|
||||
}
|
||||
else
|
||||
this.context.debug(`not cleaning ${dir}`);
|
||||
});
|
||||
}
|
||||
this.init();
|
||||
}
|
||||
@ -19774,6 +19787,11 @@ class TsCache {
|
||||
this.typesCache.roll();
|
||||
}
|
||||
getCompiled(id, snapshot, transform) {
|
||||
if (this.noCache) {
|
||||
this.context.info(`${safe_5("transpiling")} '${id}'`);
|
||||
this.markAsDirty(id);
|
||||
return transform();
|
||||
}
|
||||
const name = this.makeName(id, snapshot);
|
||||
this.context.info(`${safe_5("transpiling")} '${id}'`);
|
||||
this.context.debug(` cache: '${this.codeCache.path(name)}'`);
|
||||
@ -19800,6 +19818,10 @@ class TsCache {
|
||||
return this.getDiagnostics("semantic", this.semanticDiagnosticsCache, id, snapshot, check);
|
||||
}
|
||||
checkAmbientTypes() {
|
||||
if (this.noCache) {
|
||||
this.ambientTypesDirty = true;
|
||||
return;
|
||||
}
|
||||
this.context.debug(safe_5("Ambient types:"));
|
||||
const typeNames = lodash_5(this.ambientTypes, (snapshot) => snapshot.snapshot !== undefined)
|
||||
.map((snapshot) => {
|
||||
@ -19813,6 +19835,10 @@ class TsCache {
|
||||
lodash_2(typeNames, (name) => this.typesCache.touch(name));
|
||||
}
|
||||
getDiagnostics(type, cache, id, snapshot, check) {
|
||||
if (this.noCache) {
|
||||
this.markAsDirty(id);
|
||||
return convertDiagnostic(type, check());
|
||||
}
|
||||
const name = this.makeName(id, snapshot);
|
||||
this.context.debug(` cache: '${cache.path(name)}'`);
|
||||
if (cache.exists(name) && !this.isDirty(id, true)) {
|
||||
@ -19839,6 +19865,8 @@ class TsCache {
|
||||
this.semanticDiagnosticsCache = new NoCache();
|
||||
}
|
||||
else {
|
||||
if (this.cacheDir === undefined)
|
||||
throw new Error(`this.cacheDir undefined`);
|
||||
this.codeCache = new RollingCache(`${this.cacheDir}/code`, true);
|
||||
this.typesCache = new RollingCache(`${this.cacheDir}/types`, true);
|
||||
this.syntacticDiagnosticsCache = new RollingCache(`${this.cacheDir}/syntacticDiagnostics`, true);
|
||||
@ -20045,7 +20073,7 @@ function typescript(options) {
|
||||
context = new ConsoleContext(pluginOptions.verbosity, "rpt2: ");
|
||||
context.info(`typescript version: ${tsModule.version}`);
|
||||
context.info(`tslib version: ${tslibVersion}`);
|
||||
context.info(`rollup-plugin-typescript2 version: 0.16.2`);
|
||||
context.info(`rollup-plugin-typescript2 version: 0.17.0`);
|
||||
context.debug(() => `plugin options:\n${JSON.stringify(pluginOptions, (key, value) => key === "typescript" ? `version ${value.version}` : value, 4)}`);
|
||||
context.debug(() => `rollup config:\n${JSON.stringify(rollupOptions, undefined, 4)}`);
|
||||
watchMode = process.env.ROLLUP_WATCH === "true";
|
||||
|
||||
2
dist/rollup-plugin-typescript2.cjs.js.map
vendored
2
dist/rollup-plugin-typescript2.cjs.js.map
vendored
File diff suppressed because one or more lines are too long
56
dist/rollup-plugin-typescript2.es.js
vendored
56
dist/rollup-plugin-typescript2.es.js
vendored
@ -1,7 +1,7 @@
|
||||
/* eslint-disable */
|
||||
import { existsSync, readdirSync, renameSync, readFileSync } from 'fs';
|
||||
import crypto from 'crypto';
|
||||
import { emptyDirSync, ensureFileSync, readJsonSync, removeSync, writeJsonSync, pathExistsSync } from 'fs-extra';
|
||||
import { emptyDirSync, ensureFileSync, readJsonSync, removeSync, writeJsonSync, pathExistsSync, readdirSync as readdirSync$1, statSync } from 'fs-extra';
|
||||
import os from 'os';
|
||||
import util from 'util';
|
||||
import { join, dirname, isAbsolute, relative, normalize } from 'path';
|
||||
@ -19712,23 +19712,27 @@ function convertDiagnostic(type, data) {
|
||||
});
|
||||
}
|
||||
class TsCache {
|
||||
constructor(noCache, hashIgnoreUnknown, host, cache, options, rollupConfig, rootFilenames, context) {
|
||||
constructor(noCache, hashIgnoreUnknown, host, cacheRoot, options, rollupConfig, rootFilenames, context) {
|
||||
this.noCache = noCache;
|
||||
this.host = host;
|
||||
this.cacheRoot = cacheRoot;
|
||||
this.options = options;
|
||||
this.rollupConfig = rollupConfig;
|
||||
this.context = context;
|
||||
this.cacheVersion = "7";
|
||||
this.cacheVersion = "8";
|
||||
this.cachePrefix = "rpt2_";
|
||||
this.ambientTypesDirty = false;
|
||||
this.hashOptions = { algorithm: "sha1", ignoreUnknown: false };
|
||||
this.hashOptions.ignoreUnknown = hashIgnoreUnknown;
|
||||
this.cacheDir = `${cache}/${objectHash_1({
|
||||
version: this.cacheVersion,
|
||||
rootFilenames,
|
||||
options: this.options,
|
||||
rollupConfig: this.rollupConfig,
|
||||
tsVersion: tsModule.version,
|
||||
}, this.hashOptions)}`;
|
||||
if (!noCache) {
|
||||
this.cacheDir = `${this.cacheRoot}/${this.cachePrefix}${objectHash_1({
|
||||
version: this.cacheVersion,
|
||||
rootFilenames,
|
||||
options: this.options,
|
||||
rollupConfig: this.rollupConfig,
|
||||
tsVersion: tsModule.version,
|
||||
}, this.hashOptions)}`;
|
||||
}
|
||||
this.dependencyTree = new graphlib_1({ directed: true });
|
||||
this.dependencyTree.setDefaultNodeLabel((_node) => ({ dirty: false }));
|
||||
const automaticTypes = lodash_7(tsModule.getAutomaticTypeDirectiveNames(options, tsModule.sys), (entry) => tsModule.resolveTypeReferenceDirective(entry, undefined, options, tsModule.sys))
|
||||
@ -19741,9 +19745,18 @@ class TsCache {
|
||||
this.checkAmbientTypes();
|
||||
}
|
||||
clean() {
|
||||
if (pathExistsSync(this.cacheDir)) {
|
||||
this.context.info(safe_5(`cleaning cache: ${this.cacheDir}`));
|
||||
emptyDirSync(this.cacheDir);
|
||||
if (pathExistsSync(this.cacheRoot)) {
|
||||
const entries = readdirSync$1(this.cacheRoot);
|
||||
entries.forEach((e) => {
|
||||
const dir = `${this.cacheRoot}/${e}`;
|
||||
if (e.startsWith(this.cachePrefix) && statSync(dir).isDirectory) {
|
||||
this.context.info(safe_5(`cleaning cache: ${dir}`));
|
||||
emptyDirSync(`${dir}`);
|
||||
removeSync(`${dir}`);
|
||||
}
|
||||
else
|
||||
this.context.debug(`not cleaning ${dir}`);
|
||||
});
|
||||
}
|
||||
this.init();
|
||||
}
|
||||
@ -19770,6 +19783,11 @@ class TsCache {
|
||||
this.typesCache.roll();
|
||||
}
|
||||
getCompiled(id, snapshot, transform) {
|
||||
if (this.noCache) {
|
||||
this.context.info(`${safe_5("transpiling")} '${id}'`);
|
||||
this.markAsDirty(id);
|
||||
return transform();
|
||||
}
|
||||
const name = this.makeName(id, snapshot);
|
||||
this.context.info(`${safe_5("transpiling")} '${id}'`);
|
||||
this.context.debug(` cache: '${this.codeCache.path(name)}'`);
|
||||
@ -19796,6 +19814,10 @@ class TsCache {
|
||||
return this.getDiagnostics("semantic", this.semanticDiagnosticsCache, id, snapshot, check);
|
||||
}
|
||||
checkAmbientTypes() {
|
||||
if (this.noCache) {
|
||||
this.ambientTypesDirty = true;
|
||||
return;
|
||||
}
|
||||
this.context.debug(safe_5("Ambient types:"));
|
||||
const typeNames = lodash_5(this.ambientTypes, (snapshot) => snapshot.snapshot !== undefined)
|
||||
.map((snapshot) => {
|
||||
@ -19809,6 +19831,10 @@ class TsCache {
|
||||
lodash_2(typeNames, (name) => this.typesCache.touch(name));
|
||||
}
|
||||
getDiagnostics(type, cache, id, snapshot, check) {
|
||||
if (this.noCache) {
|
||||
this.markAsDirty(id);
|
||||
return convertDiagnostic(type, check());
|
||||
}
|
||||
const name = this.makeName(id, snapshot);
|
||||
this.context.debug(` cache: '${cache.path(name)}'`);
|
||||
if (cache.exists(name) && !this.isDirty(id, true)) {
|
||||
@ -19835,6 +19861,8 @@ class TsCache {
|
||||
this.semanticDiagnosticsCache = new NoCache();
|
||||
}
|
||||
else {
|
||||
if (this.cacheDir === undefined)
|
||||
throw new Error(`this.cacheDir undefined`);
|
||||
this.codeCache = new RollingCache(`${this.cacheDir}/code`, true);
|
||||
this.typesCache = new RollingCache(`${this.cacheDir}/types`, true);
|
||||
this.syntacticDiagnosticsCache = new RollingCache(`${this.cacheDir}/syntacticDiagnostics`, true);
|
||||
@ -20041,7 +20069,7 @@ function typescript(options) {
|
||||
context = new ConsoleContext(pluginOptions.verbosity, "rpt2: ");
|
||||
context.info(`typescript version: ${tsModule.version}`);
|
||||
context.info(`tslib version: ${tslibVersion}`);
|
||||
context.info(`rollup-plugin-typescript2 version: 0.16.2`);
|
||||
context.info(`rollup-plugin-typescript2 version: 0.17.0`);
|
||||
context.debug(() => `plugin options:\n${JSON.stringify(pluginOptions, (key, value) => key === "typescript" ? `version ${value.version}` : value, 4)}`);
|
||||
context.debug(() => `rollup config:\n${JSON.stringify(rollupOptions, undefined, 4)}`);
|
||||
watchMode = process.env.ROLLUP_WATCH === "true";
|
||||
|
||||
2
dist/rollup-plugin-typescript2.es.js.map
vendored
2
dist/rollup-plugin-typescript2.es.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/tscache.d.ts
vendored
4
dist/tscache.d.ts
vendored
@ -25,10 +25,12 @@ export declare function convertDiagnostic(type: string, data: tsTypes.Diagnostic
|
||||
export declare class TsCache {
|
||||
private noCache;
|
||||
private host;
|
||||
private cacheRoot;
|
||||
private options;
|
||||
private rollupConfig;
|
||||
private context;
|
||||
private cacheVersion;
|
||||
private cachePrefix;
|
||||
private dependencyTree;
|
||||
private ambientTypes;
|
||||
private ambientTypesDirty;
|
||||
@ -38,7 +40,7 @@ export declare class TsCache {
|
||||
private semanticDiagnosticsCache;
|
||||
private syntacticDiagnosticsCache;
|
||||
private hashOptions;
|
||||
constructor(noCache: boolean, hashIgnoreUnknown: boolean, host: tsTypes.LanguageServiceHost, cache: string, options: tsTypes.CompilerOptions, rollupConfig: any, rootFilenames: string[], context: IContext);
|
||||
constructor(noCache: boolean, hashIgnoreUnknown: boolean, host: tsTypes.LanguageServiceHost, cacheRoot: string, options: tsTypes.CompilerOptions, rollupConfig: any, rootFilenames: string[], context: IContext);
|
||||
clean(): void;
|
||||
setDependency(importee: string, importer: string): void;
|
||||
walkTree(cb: (id: string) => void | false): void;
|
||||
|
||||
2
dist/tscache.d.ts.map
vendored
2
dist/tscache.d.ts.map
vendored
@ -1 +1 @@
|
||||
{"version":3,"file":"tscache.d.ts","sourceRoot":"","sources":["src/tscache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAOrC,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAMtC,MAAM,WAAW,KAAK;IAErB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC;CAC5B;AAED,MAAM,WAAW,WAAW;IAE3B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,GAAG,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1B;AAOD,MAAM,WAAW,YAAY;IAE5B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC,kBAAkB,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACb;AAQD,wBAAgB,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B,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,eAAe,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC,UAAU,EAAE,GAAG,YAAY,EAAE;IAKzH,sBAAsB,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,eAAe,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC,UAAU,EAAE,GAAG,YAAY,EAAE;IAK/H,OAAO,CAAC,iBAAiB;IAwBzB,OAAO,CAAC,cAAc;IAkCtB,OAAO,CAAC,IAAI;IAoBZ,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,OAAO;IA8Bf,OAAO,CAAC,QAAQ;CAKhB"}
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rollup-plugin-typescript2",
|
||||
"version": "0.16.2",
|
||||
"version": "0.17.0",
|
||||
"description": "Seamless integration between Rollup and TypeScript. Now with errors.",
|
||||
"main": "dist/rollup-plugin-typescript2.cjs.js",
|
||||
"module": "dist/rollup-plugin-typescript2.es.js",
|
||||
|
||||
@ -7,7 +7,7 @@ import * as _ from "lodash";
|
||||
import { tsModule } from "./tsproxy";
|
||||
import * as tsTypes from "typescript";
|
||||
import { blue, yellow, green } from "colors/safe";
|
||||
import { emptyDirSync, pathExistsSync } from "fs-extra";
|
||||
import { emptyDirSync, pathExistsSync, readdirSync, removeSync, statSync } from "fs-extra";
|
||||
import { formatHost } from "./diagnostics-format-host";
|
||||
import { NoCache } from "./nocache";
|
||||
|
||||
@ -88,33 +88,36 @@ export function convertDiagnostic(type: string, data: tsTypes.Diagnostic[]): IDi
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export class TsCache
|
||||
{
|
||||
private cacheVersion = "7";
|
||||
private cacheVersion = "8";
|
||||
private cachePrefix = "rpt2_";
|
||||
private dependencyTree: Graph;
|
||||
private ambientTypes: ITypeSnapshot[];
|
||||
private ambientTypesDirty = false;
|
||||
private cacheDir: string;
|
||||
private cacheDir: string | undefined;
|
||||
private codeCache!: ICache<ICode | undefined>;
|
||||
private typesCache!: ICache<string>;
|
||||
private semanticDiagnosticsCache!: ICache<IDiagnostics[]>;
|
||||
private syntacticDiagnosticsCache!: ICache<IDiagnostics[]>;
|
||||
private hashOptions = { algorithm: "sha1", ignoreUnknown: false };
|
||||
|
||||
constructor(private noCache: boolean, hashIgnoreUnknown: boolean, private host: tsTypes.LanguageServiceHost, cache: string, private options: tsTypes.CompilerOptions, private rollupConfig: any, rootFilenames: string[], private context: IContext)
|
||||
constructor(private noCache: boolean, hashIgnoreUnknown: boolean, private host: tsTypes.LanguageServiceHost, private cacheRoot: string, private options: tsTypes.CompilerOptions, private rollupConfig: any, rootFilenames: string[], private context: IContext)
|
||||
{
|
||||
this.hashOptions.ignoreUnknown = hashIgnoreUnknown;
|
||||
this.cacheDir = `${cache}/${hash(
|
||||
{
|
||||
version: this.cacheVersion,
|
||||
rootFilenames,
|
||||
options: this.options,
|
||||
rollupConfig: this.rollupConfig,
|
||||
tsVersion: tsModule.version,
|
||||
},
|
||||
this.hashOptions
|
||||
)}`;
|
||||
if (!noCache)
|
||||
{
|
||||
this.cacheDir = `${this.cacheRoot}/${this.cachePrefix}${hash(
|
||||
{
|
||||
version: this.cacheVersion,
|
||||
rootFilenames,
|
||||
options: this.options,
|
||||
rollupConfig: this.rollupConfig,
|
||||
tsVersion: tsModule.version,
|
||||
},
|
||||
this.hashOptions
|
||||
)}`;
|
||||
}
|
||||
|
||||
this.dependencyTree = new Graph({ directed: true });
|
||||
this.dependencyTree.setDefaultNodeLabel((_node: string) => ({ dirty: false }));
|
||||
@ -134,10 +137,21 @@ export class TsCache
|
||||
|
||||
public clean()
|
||||
{
|
||||
if (pathExistsSync(this.cacheDir))
|
||||
if (pathExistsSync(this.cacheRoot))
|
||||
{
|
||||
this.context.info(blue(`cleaning cache: ${this.cacheDir}`));
|
||||
emptyDirSync(this.cacheDir);
|
||||
const entries = readdirSync(this.cacheRoot);
|
||||
entries.forEach((e) =>
|
||||
{
|
||||
const dir = `${this.cacheRoot}/${e}`;
|
||||
if (e.startsWith(this.cachePrefix) && statSync(dir).isDirectory)
|
||||
{
|
||||
this.context.info(blue(`cleaning cache: ${dir}`));
|
||||
emptyDirSync(`${dir}`);
|
||||
removeSync(`${dir}`);
|
||||
}
|
||||
else
|
||||
this.context.debug(`not cleaning ${dir}`);
|
||||
});
|
||||
}
|
||||
|
||||
this.init();
|
||||
@ -177,6 +191,13 @@ export class TsCache
|
||||
|
||||
public getCompiled(id: string, snapshot: tsTypes.IScriptSnapshot, transform: () => ICode | undefined): ICode | undefined
|
||||
{
|
||||
if (this.noCache)
|
||||
{
|
||||
this.context.info(`${blue("transpiling")} '${id}'`);
|
||||
this.markAsDirty(id);
|
||||
return transform();
|
||||
}
|
||||
|
||||
const name = this.makeName(id, snapshot);
|
||||
|
||||
this.context.info(`${blue("transpiling")} '${id}'`);
|
||||
@ -215,6 +236,12 @@ export class TsCache
|
||||
|
||||
private checkAmbientTypes(): void
|
||||
{
|
||||
if (this.noCache)
|
||||
{
|
||||
this.ambientTypesDirty = true;
|
||||
return;
|
||||
}
|
||||
|
||||
this.context.debug(blue("Ambient types:"));
|
||||
const typeNames = _.filter(this.ambientTypes, (snapshot) => snapshot.snapshot !== undefined)
|
||||
.map((snapshot) =>
|
||||
@ -233,6 +260,12 @@ export class TsCache
|
||||
|
||||
private getDiagnostics(type: string, cache: ICache<IDiagnostics[]>, id: string, snapshot: tsTypes.IScriptSnapshot, check: () => tsTypes.Diagnostic[]): IDiagnostics[]
|
||||
{
|
||||
if (this.noCache)
|
||||
{
|
||||
this.markAsDirty(id);
|
||||
return convertDiagnostic(type, check());;
|
||||
}
|
||||
|
||||
const name = this.makeName(id, snapshot);
|
||||
|
||||
this.context.debug(` cache: '${cache.path(name)}'`);
|
||||
@ -270,6 +303,8 @@ export class TsCache
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.cacheDir === undefined)
|
||||
throw new Error(`this.cacheDir undefined`);
|
||||
this.codeCache = new RollingCache<ICode>(`${this.cacheDir}/code`, true);
|
||||
this.typesCache = new RollingCache<string>(`${this.cacheDir}/types`, true);
|
||||
this.syntacticDiagnosticsCache = new RollingCache<IDiagnostics[]>(`${this.cacheDir}/syntacticDiagnostics`, true);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user