Skip to content

Commit f861350

Browse files
authored
- disabling cache in watch mode (#452)
1 parent 59817c4 commit f861350

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/index.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
166166
service = tsModule.createLanguageService(servicesHost, documentRegistry);
167167
servicesHost.setLanguageService(service);
168168

169-
cache = new TsCache(pluginOptions.clean, pluginOptions.objectHashIgnoreUnknownHack, servicesHost, pluginOptions.cacheRoot, parsedConfig.options, rollupOptions, parsedConfig.fileNames, context);
169+
const runClean = pluginOptions.clean;
170+
const noCache = pluginOptions.clean || watchMode;
171+
172+
cache = new TsCache(noCache, runClean, pluginOptions.objectHashIgnoreUnknownHack, servicesHost, pluginOptions.cacheRoot, parsedConfig.options, rollupOptions, parsedConfig.fileNames, context);
170173

171174
// reset transformedFiles Set on each watch cycle
172175
transformedFiles = new Set<string>();

src/tscache.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ export class TsCache
7878
private syntacticDiagnosticsCache!: ICache<IDiagnostics[]>;
7979
private hashOptions = { algorithm: "sha1", ignoreUnknown: false };
8080

81-
constructor(private noCache: boolean, hashIgnoreUnknown: boolean, private host: tsTypes.LanguageServiceHost, private cacheRoot: string, private options: tsTypes.CompilerOptions, private rollupConfig: any, rootFilenames: string[], private context: RollupContext)
81+
constructor(private noCache: boolean, runClean: boolean, hashIgnoreUnknown: boolean, private host: tsTypes.LanguageServiceHost, private cacheRoot: string, private options: tsTypes.CompilerOptions, private rollupConfig: any, rootFilenames: string[], private context: RollupContext)
8282
{
8383
this.dependencyTree = new Graph({ directed: true });
8484
this.dependencyTree.setDefaultNodeLabel((_node: string) => ({ dirty: false }));
8585

86-
if (noCache)
87-
{
86+
if (runClean)
8887
this.clean();
88+
89+
if (noCache)
8990
return;
90-
}
9191

9292
this.hashOptions.ignoreUnknown = hashIgnoreUnknown;
9393
this.cacheDir = `${this.cacheRoot}/${this.cachePrefix}${objHash(

0 commit comments

Comments
 (0)