extract-css-chunks-webpack-plugin: this[MODULE_TYPE] is not a function

TypeError: this[MODULE_TYPE] is not a function under version 4.x when used in a node build process akin to https://github.com/nozzle/react-static/blob/master/packages/react-static-plugin-css-modules/src/node.api.js (despite updating the API as noted in the changelog)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 8
  • Comments: 20

Most upvoted comments

Any update on this one, please? Same issue.

Was this ever resolved? I am still getting this issue as well

Please re-open this, the latest version is very broken.

https://github.com/aendrew/extract-css-chunks-webpack-plugin-162

I use sass-loader in this repro because that was my original error case but it still yields the same error if you comment it out.

Edit: This might be more an issue with my React SSR setup/html-webpack-plugin because the same issue also seems to occur with mini-css-extract-plugin if I import a child stylesheet anywhere. If I import only in client/index.js (which avoids html-webpack-plugin) everything seems to work… Please let me know if I should open a new issue about this specifically.

Can anyone help me how to fix TypeError: Class constructor HookCodeFactory cannot be invoked without ‘new’

This is happening in production

“webpack”: “~4.25.1”

[02:47:00][npm run portal-prod] E:\BuildAgent\work\83d9728970ba3129\node_modules\tapable\lib\SyncWaterfallHook.js:24
[02:47:00][npm run portal-prod] 		});
[02:47:00][npm run portal-prod]                                          ^
[02:47:00][npm run portal-prod] TypeError: Class constructor HookCodeFactory cannot be invoked without 'new'
[02:47:00][npm run portal-prod]     at new SyncWaterfallHookCodeFactory (E:\BuildAgent\work\83d9728970ba3129\node_modules\tapable\lib\SyncWaterfallHook.js:24:42)
[02:47:00][npm run portal-prod]     at Object.<anonymous> (E:\BuildAgent\work\83d9728970ba3129\node_modules\tapable\lib\SyncWaterfallHook.js:28:17)
[02:47:00][npm run portal-prod]     at Module._compile (E:\BuildAgent\work\83d9728970ba3129\node_modules\v8-compile-cache\v8-compile-cache.js:194:30)
[02:47:00][npm run portal-prod]     at Module.m._compile (E:\BuildAgent\work\83d9728970ba3129\node_modules\ts-node\src\index.ts:536:23)
[02:47:00][npm run portal-prod]     at Module._extensions..js (module.js:664:10)
[02:47:00][npm run portal-prod]     at Object.require.extensions.(anonymous function) [as .js] (E:\BuildAgent\work\83d9728970ba3129\node_modules\ts-node\src\index.ts:539:12)
[02:47:00][npm run portal-prod]     at Module.load (module.js:566:32)
[02:47:00][npm run portal-prod]     at tryModuleLoad (module.js:506:12)
[02:47:00][npm run portal-prod]     at Function.Module._load (module.js:498:3)
[02:47:00][npm run portal-prod]     at Module.require (module.js:597:17)

Webpack.config

{
	test: /\.(scss|sass|css|)$/,
			use: [
					MiniCssExtractPlugin.loader,
					"css-loader",
					"sass-loader"
				]
			}
	plugins: [
		new CleanWebpackPlugin(['dist']),
		new MiniCssExtractPlugin({
			filename: 'bundle.css'
		}),
		new webpack.DefinePlugin({
			'process.env.NODE_ENV': JSON.stringify('production')
		}),

Also having the same issue.

I’ll take a look and consult with some webpack authors. Thanks for bringing this to my attention

I appreciate it. Any help you have. You helped me earlier by creating the React Static plugin so I appreciate any insight.