Skip to content

Watcher gets an instance of IgnoringWatchFileSystem and errors #441

@herschel666

Description

@herschel666

In my Webpack-setup I'm ignoring some .d.ts-files by adding Webpack's WatchIgnorePlugin-plugin. These ignored files lead to the watchFileSystem of the webpack-compiler not being an instance of NodeWatchFileSystem, but of IgnoringWatchFileSystem.

This again makes src/watch-run.ts throw an error, because it expects the watcher-property to be on watching.compiler.watchFileSystem. But instances of the IgnoringWatchFileSystem have their instance of NodeWatchFileSystem on the wfs-property.

node_modules/ts-loader/dist/watch-run.js:10
        var mtimes = watching.compiler.watchFileSystem.watcher.mtimes;
                                                              ^
TypeError: Cannot read property 'mtimes' of undefined

This can easily be fixed by doing:

function makeWatchRun(
    instance: interfaces.TSInstance
) {
    return (watching: interfaces.WebpackWatching, cb: () => void) => {
        const watcher = watching.compiler.watchFileSystem.watcher ||
            watching.compiler.watchFileSystem.wfs.watcher;
        

However I'm not sure if this is actually a problem of the ts-loader. Maybe .ts-files handled by the WatchIgnorePlugin-plugin must not run through the ts-loader at all?!?

Can someone with more knowledge of the internals of Webpack provide an oppinion? This would be great! :-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions