Fork-ts-checker-webpack-plugin: TypeError: Cannot read property 'callAsync' of undefined on webpack.watch

Created on 17 Oct 2018  路  2Comments  路  Source: TypeStrong/fork-ts-checker-webpack-plugin

Issue:
ForkTsCheckerWebpackPlugin is causing the webpack.watch reload to throw the following error:

\node_modules\fork-ts-checker-webpack-plugin\lib\index.js:223
                _this.compiler.hooks.forkTsCheckerServiceBeforeStart.callAsync(function () {
                                                                    ^

TypeError: Cannot read property 'callAsync' of undefined
    at Proxy.<anonymous> (.\node_modules\fork-ts-checker-webpack-plugin\lib\index.js:223:69)
    at args (.\node_modules\speed-measure-webpack-plugin\WrappedPlugin\index.js:52:19)
    at SyncHook.eval [as call] (eval at create (.\node_modules\tapable\lib\HookCodeFactory.js:19:10), <anonymous>:7:1)
    at hooks.beforeCompile.callAsync.err (.\node_modules\webpack\lib\Compiler.js:532:23)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (.\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:6:1)
    at Compiler.compile (.\node_modules\webpack\lib\Compiler.js:529:28)
    at compiler.hooks.watchRun.callAsync.err (.\node_modules\webpack\lib\Watching.js:77:18)
    at _err0 (eval at create (.\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:20:1)
    at func.apply.argsButLast.map.concat.callbackArgs (.\node_modules\speed-measure-webpack-plugin\WrappedPlugin\index.js:44:9)
    at Proxy.watchRun (.\node_modules\fork-ts-checker-webpack-plugin\lib\index.js:140:13)
    at args (.\node_modules\speed-measure-webpack-plugin\WrappedPlugin\index.js:40:16)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (.\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:7:1)
    at Watching._go (.\node_modules\webpack\lib\Watching.js:40:32)
    at Watching._invalidate (.\node_modules\webpack\lib\Watching.js:165:9)
    at watcher.compiler.watchFileSystem.watch (.\node_modules\webpack\lib\Watching.js:136:10)
    at Watchpack.watcher.once (.\node_modules\webpack\lib\node\NodeWatchFileSystem.js:54:4)
    at Object.onceWrapper (events.js:318:30)
    at emitTwo (events.js:125:13)
    at Watchpack.emit (events.js:213:7)
    at Watchpack._onTimeout (.\node_modules\watchpack\lib\watchpack.js:144:7)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)

Everything bundles fine the first time. But on reload, it exits with that error.
When commenting out ForkTsCheckerWebpackPlugin, webpack.watch works fine.

Here's my webpack.config.js

const path = require('path');
const webpack = require('webpack');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

const SpeedMeasurePlugin = require("speed-measure-webpack-plugin");
const smp = new SpeedMeasurePlugin();

const VueLoaderPlugin = require("vue-loader/lib/plugin");

module.exports = smp.wrap({
    entry: {
        /** multiple entry points **/
    },
    optimization: {
        splitChunks: {
            cacheGroups: {
                vendors: {
                    name: "vendor",
                    chunks: "initial",
                    test: /[\\/]node_modules[\\/]/
                },
                commons: {
                    name: "common",
                    chunks: "initial",
                    minChunks: 2
                }
            }
        }
    },
    output: {
        path: path.resolve(__dirname, './dist'),
        pathinfo: false,
        publicPath: '/dist/',
        filename: '[name].bundle.js'
    },
    plugins: [        
        new ForkTsCheckerWebpackPlugin({vue: true,tslint: false,workers: 2}),
        new VueLoaderPlugin(),
        new webpack.IgnorePlugin(/** external libraries **/)
    ],
    module: {
        rules: [
            {
                test: /\.vue$/,
                loader: 'vue-loader',
                include: /src/,
                exclude: /node_modules/,
                options: {
                    loaders: {
                    }
                }
            },
            {
                test: /\.tsx?$/,
                loader: 'ts-loader',
                include: /src/,
                exclude: /node_modules/,
                options: {
                    appendTsSuffixTo: [/\.vue$/],
                    transpileOnly: true,
                    compilerOptions: {
                        "noEmit": false
                    }
                }
            }
        ]
    },
    resolve: {
        symlinks: false,
        extensions: ['.ts', '.js', '.vue', '.json'],
        alias: {
            'vue$': 'vue/dist/vue.esm.js'
        }
    },
    performance: {
        hints: false
    },
    externals: [ /** external libraries**/ ]
});

Versions:
webpack 4.20.2
webpack-cli 3.1.2
typescript 3.1.1
ts-loader 5.2.2
fork-ts-checker-webpack-plugin 0.4.10

If you need more information, please let me know. Thanks in advance.

Most helpful comment

Speed Measure Plugin seems to be causing this. Works fine without the 'smp.wrap' (for me).

All 2 comments

Speed Measure Plugin seems to be causing this. Works fine without the 'smp.wrap' (for me).

Removing the smp.wrap fixed the problem. Thanks! Closing the issue.

Was this page helpful?
0 / 5 - 0 ratings