jharris4 / html-webpack-tags-plugin

lets you define html tags to inject with html-webpack-plugin
MIT License
255 stars 31 forks source link

HtmlWebpackPlugin.getHooks is not a function #35

Closed fookoo closed 5 years ago

fookoo commented 6 years ago

Hi

stack: "devDependencies": { "@babel/core": "^7.1.0", "@babel/plugin-proposal-class-properties": "^7.1.0", "@babel/preset-env": "^7.1.0", "@babel/preset-react": "^7.0.0", "babel-loader": "^8.0.2", "css-loader": "^1.0.0", "file-loader": "^2.0.0", "html-loader": "^0.5.5", "html-webpack-include-assets-plugin": "^1.0.5", "html-webpack-plugin": "^3.2.0", "node-sass": "^4.7.2", "sass-loader": "^7.1.0", "speed-measure-webpack-plugin": "^1.2.2", "style-loader": "^0.23.0", "url-loader": "^1.1.1", "webpack": "^4.19.1", "webpack-cli": "^3.1.0", "webpack-serve": "^2.0.2" }

how i am using plugin:

new HtmlWebpackIncludeAssetsPlugin({ assets: ['./dist/library.js'], append: false, jsExtensions: ['.js'] })

what error i got:

TypeError: HtmlWebpackPlugin.getHooks is not a function at Proxy.onCompilation (node_modules\html-webpack-include-assets-plugin\index.js:358:39) 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>:13:1) at SyncHook.lazyCompileHook (node_modules\tapable\lib\Hook.js:154:20) at Compiler.newCompilation (node_modules\webpack\lib\Compiler.js:504:26) at hooks.beforeCompile.callAsync.err (node_modules\webpack\lib\Compiler.js:540:29) at _err0 (eval at create (node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:11:1) at func.apply.argsButLast.map.concat.callbackArgs (node_modules\speed-measure-webpack-plugin\WrappedPlugin\index.js:44:9) at Proxy.compiler.hooks.beforeCompile.tapAsync (node_modules\webpack\lib\DllReferencePlugin.js:68: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 AsyncSeriesHook.lazyCompileHook (node_modules\tapable\lib\Hook.js:154:20) at Compiler.compile (node_modules\webpack\lib\Compiler.js:535:28) at readRecords.err (node_modules\webpack\lib\Compiler.js:274:11) at Compiler.readRecords (node_modules\webpack\lib\Compiler.js:402:11) at hooks.run.callAsync.err (node_modules\webpack\lib\Compiler.js:271:10) at AsyncSeriesHook.eval [as callAsync] (eval at create (node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:6:1) at AsyncSeriesHook.lazyCompileHook (node_modules\tapable\lib\Hook.js:154:20) at hooks.beforeRun.callAsync.err (node_modules\webpack\lib\Compiler.js:268:19) at AsyncSeriesHook.eval [as callAsync] (eval at create (node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:15:1) at AsyncSeriesHook.lazyCompileHook (node_modules\tapable\lib\Hook.js:154:20) at Compiler.run (node_modules\webpack\lib\Compiler.js:265:24) at processOptions (node_modules\webpack-cli\bin\cli.js:525:20) at yargs.parse (node_modules\webpack-cli\bin\cli.js:528:3) at Object.parse (node_modules\yargs\yargs.js:563:18) at node_modules\webpack-cli\bin\cli.js:219:8 at Object.<anonymous> (node_modules\webpack-cli\bin\cli.js:530:3) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at Object.<anonymous> (node_modules\webpack\bin\webpack.js:155:2) at Module._compile (module.js:652:30)

jharris4 commented 6 years ago

Interesting, it looks like speed-measure-webpack-plugin might actually be triggering the case where this error is thrown.

I'll try to look into it, but I have a flight to catch later this afternoon, so worst case please just stick to using 1.0.4 until I get a new release out.

jharris4 commented 6 years ago

@fookoo Are you sure you have the html-webpack-plugin in your webpack config (BEFORE this plugin)?

I reviewed the code, and the only way I can see this error happening is if you don't have the plugin loaded...

jharris4 commented 6 years ago

I get the error message you described only if html-webpack-plugin is missing. I've changed the code to throw an error for this case to make it more obvious what's happening.

Please let me know if adding the missing plugin fixes the issue. Otherwise I'll close the issue.

fookoo commented 6 years ago

As you can see i have got html-webpack-plugin in my package.json, as well as in webpack.config.js (just before html-webpack-include-assets-plugin)

jharris4 commented 6 years ago

Ok, you didn’t include your full webpack config so it wasn’t possible to tell.

Is there an error with version 1.0.4 or only with version 1.0.5 of this plugin?

jharris4 commented 6 years ago

Ok, I just tried adding speed-measure-webpack-plugin to my webpack config, and it causes the error. Looks like there's a bug in that plugin that needs to be fixed...

Adherentman commented 6 years ago

@jharris4 yes, add speed-measure-webpack-plugin,the error will appear When can I fix it, or where the problem causes conflict, it can be explained. We can help

jharris4 commented 5 years ago

Closing due to inactivity. @Adherentman hopefully you've managed to address the bug in speed-measure-webpack-plugin ?

jharris4 commented 5 years ago

looks like this is still not fixed in speed-measure-webpack-plugin.

Possibly related issue: https://github.com/stephencookdev/speed-measure-webpack-plugin/issues/55

raman-kazhadub commented 5 years ago

@jharris4 Thanks a lot.