colbyfayock / html-webpack-partials-plugin

🛠 Easy HTML partials for Webpack without a custom index!
MIT License
68 stars 20 forks source link

Cannot read property 'compilation' of undefined #5

Closed jessegavin closed 5 years ago

jessegavin commented 5 years ago

I ran into problems with this on a project, so I created an extremely stripped down repo try to get to the bottom of it.

The project is using Webpack 4.x with Webpack CLI 3.x

When I run webpack on the project I get the following error:

/usr/local/lib/node_modules/webpack/bin/webpack.js:315
                throw e;
                ^

TypeError: Cannot read property 'compilation' of undefined
    at HtmlWebpackPartialsPlugin.apply (/Users/me/code/webpack-partials-demo/node_modules/html-webpack-partials-plugin/index.js:19:20)
    at Compiler.apply (/usr/local/lib/node_modules/webpack/node_modules/tapable/lib/Tapable.js:306:16)
    at webpack (/usr/local/lib/node_modules/webpack/lib/webpack.js:32:19)
    at processOptions (/usr/local/lib/node_modules/webpack/bin/webpack.js:305:14)
    at Object.<anonymous> (/usr/local/lib/node_modules/webpack/bin/webpack.js:363:1)
    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 Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)
    at bootstrap_node.js:609:3
colbyfayock commented 5 years ago

i'll take a look and see what i can find out 🤔

colbyfayock commented 5 years ago

thanks for creating that repo. super handy. it looks like it's a dependency issue, the latest version of html-webpack-partials-plugin requires html-webpack-plugin v4+ which is still in beta i guess, so i think that's why it's not pulling in the latest 😞

that being said, there are 2 options here...

1) you can upgrade to the latest html-webpack-plugin (tested this on your repo)

yarn add html-webpack-plugin@4.0.0-beta.5

2) you can install an older version of html-webpack-partials-plugin, which uses html-webpack-plugin 3.2 (haven't tested this)

yarn add html-webpack-partials-plugin@0.4.1

aside from that, i'll see if i can better manage the dependencies on the plugin or at least i can make it more clear in the README

let me know if either of those work out for you. i dont think there were any changes to the webpack config API with the updated html-webpack-plugin 🤔

jessegavin commented 5 years ago

Works like a charm with html-webpack-plugin@4.0.0-beta.5. Thanks for your help!