Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'call' of undefined? #161

Closed
Adherentman opened this issue Sep 29, 2018 · 3 comments
Closed

Cannot read property 'call' of undefined? #161

Adherentman opened this issue Sep 29, 2018 · 3 comments

Comments

@Adherentman
Copy link

I don't know what caused this problem.

version:

  • webpack ^4.20.2
  • fork-ts-checker-webpack-plugin ^0.4.9
  • ts-loader ^5.2.1
  • cache-loader ^1.2.2
  • thread-loader ^1.2.0

this is my config:

const path = require('path');
const os = require('os');
const webpack = require('webpack');
const HtmlWebpacPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
// const WebpackDeepScopeAnalysisPlugin = require('webpack-deep-scope-plugin')
// 	.default;
const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');

const devMode = process.env.NODE_ENV !== 'production';

const HtmlPlugin = new HtmlWebpacPlugin({
	template: path.resolve(__dirname, './index.html'),
	title: 'xxxx',
	favicon: './favicon.ico',
});

const CleanDistPlugin = new CleanWebpackPlugin(['cms2'], {
	root: '/project/dist/interface/www/',
	verbose: true,
});

const extractSassPlugin = new MiniCssExtractPlugin({
	filename: devMode ? 'css/[name].css' : 'css/[name].[hash].css',
	chunkFilename: devMode ? 'css/[name].css' : 'css/[name].[hash].css',
});

const smp = new SpeedMeasurePlugin();

module.exports = smp.wrap({
	context: path.resolve(process.cwd()),
	entry: './src/index.tsx',
	output: {
		path: path.resolve(__dirname, '../../../dist/interface/www/cms2'),
		publicPath: '/cms2/',
		filename: './scripts/[name].[hash].js',
		chunkFilename: './scripts/[name].[hash].js',
	},
	resolve: {
		extensions: ['.ts', '.tsx', '.js', '.jsx'],
	},
	module: {
		rules: [
			{
				test: /\.tsx?$/,
				use: [
					{ loader: 'cache-loader' },
					{
						loader: 'thread-loader',
						options: {
							workers: require('os').cpus().length - 1,
						},
					},
					{
						loader: 'ts-loader',
						options: {
							happyPackMode: true,
						},
					},
				],
				exclude: path.resolve(process.cwd(), 'node_modules'),
			},
			{
				test: /\.scss$/,
				use: [
					MiniCssExtractPlugin.loader,
					{
						loader: 'css-loader',
						options: {
							modules: true,
							importLoader: 2,
						},
					},
					'sass-loader',
				],
			},
			{
				test: /\.(png|svg|jpg|gif)$/,
				use: [
					{
						loader: 'file-loader',
						options: {
							name: devMode ? 'images/[name].[ext]' : 'images/[hash].[ext]',
						},
					},
				],
			},
		],
	},
	plugins: [
		HtmlPlugin,
		CleanDistPlugin,
		extractSassPlugin,
		new ForkTsCheckerWebpackPlugin({ checkSyntacticErrors: true }),
		// new WebpackDeepScopeAnalysisPlugin(),
	],
});

this is terminal log:

/project/interface/www/cms2/node_modules/fork-ts-checker-webpack-plugin/lib/index.js:424             
            this.compiler.hooks.forkTsCheckerReceive.call(this.diagnostics, this.lints);            
                                                     ^                                               
                                                                                                     
TypeError: Cannot read property 'call' of undefined                                                  
    at ForkTsCheckerWebpackPlugin.handleServiceMessage (/project/interface/www/cms2/node_modules/fork-│
ts-checker-webpack-plugin/lib/index.js:424:54)                                                       
    at ChildProcess.<anonymous> (/project/interface/www/cms2/node_modules/fork-ts-checker-webpack-plug│
in/lib/index.js:382:70)                                                                              
    at ChildProcess.emit (events.js:182:13)                                                          
    at emit (internal/child_process.js:811:12)                                                       
    at process._tickCallback (internal/process/next_tick.js:63:19)

what can i do?

@johnnyreilly
Copy link
Member

It might be worth you comparing your setup with a working example: https://github.com/TypeStrong/ts-loader/tree/master/examples/thread-loader

@Adherentman
Copy link
Author

@johnnyreilly thanks, i copy this example, But this problem still exists

@charlesbetros
Copy link

Is this the same as #170? If so Speed Measure Plugin seems to be causing this. Works fine without the 'smp.wrap' (for me).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants