Skip to content

Commit

Permalink
- disabling cache in watch mode (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
ezolenko committed Jun 20, 2023
1 parent 59817c4 commit f861350
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/index.ts
Expand Up @@ -166,7 +166,10 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
service = tsModule.createLanguageService(servicesHost, documentRegistry);
servicesHost.setLanguageService(service);

cache = new TsCache(pluginOptions.clean, pluginOptions.objectHashIgnoreUnknownHack, servicesHost, pluginOptions.cacheRoot, parsedConfig.options, rollupOptions, parsedConfig.fileNames, context);
const runClean = pluginOptions.clean;
const noCache = pluginOptions.clean || watchMode;

cache = new TsCache(noCache, runClean, pluginOptions.objectHashIgnoreUnknownHack, servicesHost, pluginOptions.cacheRoot, parsedConfig.options, rollupOptions, parsedConfig.fileNames, context);

// reset transformedFiles Set on each watch cycle
transformedFiles = new Set<string>();
Expand Down
8 changes: 4 additions & 4 deletions src/tscache.ts
Expand Up @@ -78,16 +78,16 @@ export class TsCache
private syntacticDiagnosticsCache!: ICache<IDiagnostics[]>;
private hashOptions = { algorithm: "sha1", ignoreUnknown: false };

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)
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)
{
this.dependencyTree = new Graph({ directed: true });
this.dependencyTree.setDefaultNodeLabel((_node: string) => ({ dirty: false }));

if (noCache)
{
if (runClean)
this.clean();

if (noCache)
return;
}

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

0 comments on commit f861350

Please sign in to comment.