Skip to content

Commit 3caf12c

Browse files
committed
Fix population of webpack FS in Windows.
1 parent 06fb4ea commit 3caf12c

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

packages/webpack/src/compiler_host.ts

+12-7
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,20 @@ export class WebpackCompilerHost implements ts.CompilerHost {
135135
return;
136136
}
137137

138+
const isWindows = process.platform.startsWith('win');
138139
for (const fileName of Object.keys(this._files)) {
139140
const stats = this._files[fileName];
140-
fs._statStorage.data[fileName] = [null, stats];
141-
fs._readFileStorage.data[fileName] = [null, stats.content];
141+
// If we're on windows, we need to populate with the proper path separator.
142+
const path = isWindows ? fileName.replace(/\//g, '\\') : fileName;
143+
fs._statStorage.data[path] = [null, stats];
144+
fs._readFileStorage.data[path] = [null, stats.content];
142145
}
143-
for (const path of Object.keys(this._directories)) {
144-
const stats = this._directories[path];
145-
const dirs = this.getDirectories(path);
146-
const files = this.getFiles(path);
146+
for (const dirName of Object.keys(this._directories)) {
147+
const stats = this._directories[dirName];
148+
const dirs = this.getDirectories(dirName);
149+
const files = this.getFiles(dirName);
150+
// If we're on windows, we need to populate with the proper path separator.
151+
const path = isWindows ? dirName.replace(/\//g, '\\') : dirName;
147152
fs._statStorage.data[path] = [null, stats];
148153
fs._readdirStorage.data[path] = [null, files.concat(dirs)];
149154
}
@@ -215,7 +220,7 @@ export class WebpackCompilerHost implements ts.CompilerHost {
215220
onError?: (message: string) => void, sourceFiles?: ts.SourceFile[]): void => {
216221
fileName = this._resolve(fileName);
217222
this._setFileContent(fileName, data);
218-
}
223+
};
219224
}
220225

221226
getCurrentDirectory(): string {

0 commit comments

Comments
 (0)