mirror of
https://github.com/ezolenko/rollup-plugin-typescript2.git
synced 2025-12-08 19:06:16 +00:00
- normalizing paths used as snapshot cache keys (#6)
This commit is contained in:
parent
f4cd9b488e
commit
65fb8834ed
6
dist/rollup-plugin-typescript2.cjs.js
vendored
6
dist/rollup-plugin-typescript2.cjs.js
vendored
@ -127,12 +127,14 @@ var LanguageServiceHost = (function () {
|
||||
this.versions = {};
|
||||
};
|
||||
LanguageServiceHost.prototype.setSnapshot = function (fileName, data) {
|
||||
fileName = this.normalize(fileName);
|
||||
var snapshot = ts.ScriptSnapshot.fromString(data);
|
||||
this.snapshots[fileName] = snapshot;
|
||||
this.versions[fileName] = (this.versions[fileName] || 0) + 1;
|
||||
return snapshot;
|
||||
};
|
||||
LanguageServiceHost.prototype.getScriptSnapshot = function (fileName) {
|
||||
fileName = this.normalize(fileName);
|
||||
if (_.has(this.snapshots, fileName))
|
||||
return this.snapshots[fileName];
|
||||
if (fs.existsSync(fileName)) {
|
||||
@ -146,6 +148,7 @@ var LanguageServiceHost = (function () {
|
||||
return this.cwd;
|
||||
};
|
||||
LanguageServiceHost.prototype.getScriptVersion = function (fileName) {
|
||||
fileName = this.normalize(fileName);
|
||||
return (this.versions[fileName] || 0).toString();
|
||||
};
|
||||
LanguageServiceHost.prototype.getScriptFileNames = function () {
|
||||
@ -157,6 +160,9 @@ var LanguageServiceHost = (function () {
|
||||
LanguageServiceHost.prototype.getDefaultLibFileName = function (opts) {
|
||||
return ts.getDefaultLibFilePath(opts);
|
||||
};
|
||||
LanguageServiceHost.prototype.normalize = function (fileName) {
|
||||
return fileName.split("\\").join("/");
|
||||
};
|
||||
return LanguageServiceHost;
|
||||
}());
|
||||
|
||||
|
||||
6
dist/rollup-plugin-typescript2.es.js
vendored
6
dist/rollup-plugin-typescript2.es.js
vendored
@ -133,12 +133,14 @@ var LanguageServiceHost = (function () {
|
||||
this.versions = {};
|
||||
};
|
||||
LanguageServiceHost.prototype.setSnapshot = function (fileName, data) {
|
||||
fileName = this.normalize(fileName);
|
||||
var snapshot = ScriptSnapshot.fromString(data);
|
||||
this.snapshots[fileName] = snapshot;
|
||||
this.versions[fileName] = (this.versions[fileName] || 0) + 1;
|
||||
return snapshot;
|
||||
};
|
||||
LanguageServiceHost.prototype.getScriptSnapshot = function (fileName) {
|
||||
fileName = this.normalize(fileName);
|
||||
if (has(this.snapshots, fileName))
|
||||
return this.snapshots[fileName];
|
||||
if (existsSync(fileName)) {
|
||||
@ -152,6 +154,7 @@ var LanguageServiceHost = (function () {
|
||||
return this.cwd;
|
||||
};
|
||||
LanguageServiceHost.prototype.getScriptVersion = function (fileName) {
|
||||
fileName = this.normalize(fileName);
|
||||
return (this.versions[fileName] || 0).toString();
|
||||
};
|
||||
LanguageServiceHost.prototype.getScriptFileNames = function () {
|
||||
@ -163,6 +166,9 @@ var LanguageServiceHost = (function () {
|
||||
LanguageServiceHost.prototype.getDefaultLibFileName = function (opts) {
|
||||
return getDefaultLibFilePath(opts);
|
||||
};
|
||||
LanguageServiceHost.prototype.normalize = function (fileName) {
|
||||
return fileName.split("\\").join("/");
|
||||
};
|
||||
return LanguageServiceHost;
|
||||
}());
|
||||
|
||||
|
||||
11
src/host.ts
11
src/host.ts
@ -20,6 +20,8 @@ export class LanguageServiceHost implements ts.LanguageServiceHost
|
||||
|
||||
public setSnapshot(fileName: string, data: string): ts.IScriptSnapshot
|
||||
{
|
||||
fileName = this.normalize(fileName);
|
||||
|
||||
let snapshot = ts.ScriptSnapshot.fromString(data);
|
||||
this.snapshots[fileName] = snapshot;
|
||||
this.versions[fileName] = (this.versions[fileName] || 0) + 1;
|
||||
@ -28,6 +30,8 @@ export class LanguageServiceHost implements ts.LanguageServiceHost
|
||||
|
||||
public getScriptSnapshot(fileName: string): ts.IScriptSnapshot | undefined
|
||||
{
|
||||
fileName = this.normalize(fileName);
|
||||
|
||||
if (_.has(this.snapshots, fileName))
|
||||
return this.snapshots[fileName];
|
||||
|
||||
@ -48,6 +52,8 @@ export class LanguageServiceHost implements ts.LanguageServiceHost
|
||||
|
||||
public getScriptVersion(fileName: string)
|
||||
{
|
||||
fileName = this.normalize(fileName);
|
||||
|
||||
return (this.versions[fileName] || 0).toString();
|
||||
}
|
||||
|
||||
@ -65,4 +71,9 @@ export class LanguageServiceHost implements ts.LanguageServiceHost
|
||||
{
|
||||
return ts.getDefaultLibFilePath(opts);
|
||||
}
|
||||
|
||||
private normalize(fileName: string)
|
||||
{
|
||||
return fileName.split("\\").join("/");
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
"listFiles": true,
|
||||
"pretty": true,
|
||||
"moduleResolution": "node",
|
||||
"noEmitOnError": true,
|
||||
"noEmitOnError": false,
|
||||
"strictNullChecks": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noImplicitReturns": true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user