mirror of
https://github.com/ezolenko/rollup-plugin-typescript2.git
synced 2025-12-08 19:06:16 +00:00
fix(host): getScriptSnapshot must also call fileNames.add (#364)
- the `fileNames` Set that was previously introduced in c86e07bc caused a regression during watch mode
- this is because `setSnapshot` was updated to call `this.fileNames.add`, but `getScriptSnapshot` was not
- instead of updating both to be the same, we can just call `setSnapshot` from `getScriptSnapshot` as this code is supposed to be identical
- also rename `data` -> `source` for consistency and clarity (`source` is a more specific name)
This commit is contained in:
parent
74f6761ff6
commit
b2584971da
10
src/host.ts
10
src/host.ts
@ -27,11 +27,11 @@ export class LanguageServiceHost implements tsTypes.LanguageServiceHost
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
public setSnapshot(fileName: string, data: string): tsTypes.IScriptSnapshot
|
||||
public setSnapshot(fileName: string, source: string): tsTypes.IScriptSnapshot
|
||||
{
|
||||
fileName = normalize(fileName);
|
||||
|
||||
const snapshot = tsModule.ScriptSnapshot.fromString(data);
|
||||
const snapshot = tsModule.ScriptSnapshot.fromString(source);
|
||||
this.snapshots[fileName] = snapshot;
|
||||
this.versions[fileName] = (this.versions[fileName] || 0) + 1;
|
||||
this.fileNames.add(fileName);
|
||||
@ -47,11 +47,7 @@ export class LanguageServiceHost implements tsTypes.LanguageServiceHost
|
||||
|
||||
const source = tsModule.sys.readFile(fileName);
|
||||
if (source)
|
||||
{
|
||||
this.snapshots[fileName] = tsModule.ScriptSnapshot.fromString(source);
|
||||
this.versions[fileName] = (this.versions[fileName] || 0) + 1;
|
||||
return this.snapshots[fileName];
|
||||
}
|
||||
return this.setSnapshot(fileName, source);
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user