Skip to content
This repository was archived by the owner on Dec 1, 2019. It is now read-only.

Commit 75b41d7

Browse files
committed
fix: watch files on Windows (normalize)
1 parent 8c189f4 commit 75b41d7

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

src/checker-runtime.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ICompilerInfo, IFile } from './host';
2+
import * as path from 'path';
23
import { LoaderPlugin, LoaderPluginDef, LoaderConfig } from './instance';
34

45
let colors = require('colors/safe');
@@ -184,7 +185,7 @@ function processCompile(payload: ICompilePayload) {
184185
let message = env.compiler.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
185186
if (diagnostic.file) {
186187
let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
187-
console.error(`[${ instanceName }] ${colors.red(diagnostic.file.fileName)}:${line + 1}:${character + 1} \n ${colors.red(message)}`);
188+
console.error(`[${ instanceName }] ${colors.red(path.normalize(diagnostic.file.fileName))}:${line + 1}:${character + 1} \n ${colors.red(message)}`);
188189
} else {
189190
console.error(colors.red(`[${ instanceName }] ${ message }`));
190191
}

src/helpers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export function formatError(diagnostic) {
7474
lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
7575
}
7676
return (
77-
(diagnostic.file ? diagnostic.file.fileName : '')
77+
(diagnostic.file ? path.normalize(diagnostic.file.fileName) : '')
7878
+ (lineChar ? formatLineChar(lineChar) + ' ' : '') + "\n"
7979
+ (typeof diagnostic.messageText == "string" ?
8080
diagnostic.messageText :

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function compiler(webpack: IWebPack, text: string): void {
4141
let fileName = helpers.toUnix(webpack.resourcePath);
4242

4343
let depsInjector = {
44-
add: (depFileName) => webpack.addDependency(depFileName),
44+
add: (depFileName) => webpack.addDependency(path.normalize(depFileName)),
4545
clear: webpack.clearDependencies.bind(webpack)
4646
};
4747

src/instance.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ function setupAfterCompile(compiler, instanceName, forkChecker = false) {
416416
let declarationFile = output.outputFiles.filter(filePath =>
417417
!!filePath.name.match(/\.d.ts$/))[0];
418418
if (declarationFile) {
419-
let assetPath = path.relative(process.cwd(), declarationFile.name);
419+
let assetPath = path.normalize(path.relative(process.cwd(), declarationFile.name));
420420
compilation.assets[assetPath] = {
421421
source: () => declarationFile.text,
422422
size: () => declarationFile.text.length
@@ -426,8 +426,10 @@ function setupAfterCompile(compiler, instanceName, forkChecker = false) {
426426
}
427427

428428
instance.compiledFiles = {};
429-
compilation.fileDependencies.push.apply(compilation.fileDependencies, phantomImports);
430-
compilation.fileDependencies = _.uniq(compilation.fileDependencies);
429+
430+
let fileDeps = compilation.fileDependencies;
431+
fileDeps.push.apply(fileDeps, phantomImports.map(path.normalize));
432+
compilation.fileDependencies = _.uniq(fileDeps);
431433

432434
callback();
433435
});

0 commit comments

Comments
 (0)