fork-ts-checker-notifier-webpack-plugin
fork-ts-checker-notifier-webpack-plugin copied to clipboard
Does not work w/ latest plugin and latest webpack
ERR! Error: Error: TypeError: forkTsCheckerWebpackPlugin.getCompilerHooks is not a function
ERR! at ForkTsCheckerNotifierWebpackPlugin.apply (/Users/uri/Documents/web-gen3/node_modules/fork-ts-checker-notifier-webpack-plugin/index.js:68:23)
ERR! at webpack (/Users/uri/Documents/web-gen3/node_modules/@storybook/core/node_modules/webpack/lib/webpack.js:47:13)
ERR! at options.ignorePreview.then.previewConfig (/Users/uri/Documents/web-gen3/node_modules/@storybook/core/dist/server/dev-server.js:113:50)
ERR! at process._tickCallback (internal/process/next_tick.js:68:7)
ERR! { Error: Error: TypeError: forkTsCheckerWebpackPlugin.getCompilerHooks is nota function
ERR! at ForkTsCheckerNotifierWebpackPlugin.apply (/Users/uri/Documents/web-gen3/node_modules/fork-ts-checker-notifier-webpack-plugin/index.js:68:23)
ERR! at webpack (/Users/uri/Documents/web-gen3/node_modules/@storybook/core/node_modules/webpack/lib/webpack.js:47:13)
ERR! at options.ignorePreview.then.previewConfig (/Users/uri/Documents/web-gen3/node_modules/@storybook/core/dist/server/dev-server.js:113:50)
ERR! at process._tickCallback (internal/process/next_tick.js:68:7)
ERR! stack:
ERR! 'Error: Error: TypeError: forkTsCheckerWebpackPlugin.getCompilerHooks is not a function\n at ForkTsCheckerNotifierWebpackPlugin.apply (/Users/uri/Documents/web-gen3/node_modules/fork-ts-checker-notifier-webpack-plugin/index.js:68:23)\n at webpack (/Users/uri/Documents/web-gen3/node_modules/@storybook/core/node_modules/webpack/lib/webpack.js:47:13)\n at options.ignorePreview.then.previewConfig (/Users/uri/Documents/web-gen3/node_modules/@storybook/core/dist/server/dev-server.js:113:50)\n at process._tickCallback (internal/process/next_tick.js:68:7)' }
webpack.config:
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const ForkTsCheckerNotifierWebpackPlugin = require('fork-ts-checker-notifier-webpack-plugin');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { plugins, presets } = require('../babel.config');
module.exports = ({ config }) => {
config.module.rules.push({
test: /\.(ts|tsx)$/,
exclude: ['/node_modules/'],
use: [
{
loader: require.resolve('babel-loader'),
options: {
plugins,
presets,
},
},
{
loader: require.resolve('@storybook/addon-storysource/loader'),
options: { parser: 'typescript' },
},
{
loader: require.resolve('react-docgen-typescript-loader'),
options: {
skipPropsWithoutDoc: false,
tsconfigPath: path.join(__dirname, '../tsconfig.json'),
},
},
],
});
config.resolve.extensions.push('.ts', '.tsx');
config.plugins.push(
new ForkTsCheckerWebpackPlugin({
tsconfig: path.join(__dirname, '../tsconfig.json'),
}),
new ForkTsCheckerNotifierWebpackPlugin({ excludeWarnings: true }),
);
return config;
};
I was unable to reproduce your issue using this setup: https://github.com/TypeStrong/ts-loader/tree/master/examples/fork-ts-checker-webpack-plugin
Can you?
I get the same problem
Error: Error: TypeError: forkTsCheckerWebpackPlugin.getCompilerHooks is not a function
at ForkTsCheckerNotifierWebpackPlugin.apply (/ts-loader/examples/fork-ts-checker-webpack-plugin/node_modules/fork-ts-checker-notifier-webpack-plugin/index.js:68:23)
at webpack (/ts-loader/examples/fork-ts-checker-webpack-plugin/node_modules/webpack/lib/webpack.js:37:12)
at startDevServer (/ts-loader/examples/fork-ts-checker-webpack-plugin/node_modules/webpack-dev-server/bin/webpack-dev-server.js:145:16)
at processOptions (/ts-loader/examples/fork-ts-checker-webpack-plugin/node_modules/webpack-dev-server/bin/webpack-dev-server.js:136:3)
at Object.<anonymous> (/ts-loader/examples/fork-ts-checker-webpack-plugin/node_modules/webpack-dev-server/bin/webpack-dev-server.js:251:1)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
Apparently, the bug is when using fork-ts-checker-webpack-plugin
at version lower than 1.0.0
To reproduce it just change "fork-ts-checker-webpack-plugin": "^1.0.0",
to "fork-ts-checker-webpack-plugin": "0.5.2",
at the example package.json
Proposed fix: In this case just update fork-ts-checker-webpack-plugin
to 1.0.0 or above