shellscape / koa-webpack

Development and Hot Reload Middleware for Koa2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

need to update dependencies for webpack 3

leomao opened this issue · comments

  • Node Version: 8.1.3
  • NPM Version: 4.6.1
  • yarn Version: 0.27.3 (I use yarn)
  • koa Version: 2.3.0
  • koa-wepback Version: 0.5.1

I found that using the current version of koa-webpack will encounter the following error:

records.chunkModuleIds[chunk.id] = chunk.mapModules(function(m) {                  
                                         ^                  

TypeError: chunk.mapModules is not a function

After installing the latest webpack-dev-middleware and webpack-hot-middleware and
copying the entire index.js (from this project) into my code to substitute the original module, webpack works smoothly.

a PR here would be the best route, rather than an issue. :)

a PR here would be the best route, rather than an issue. :)

Yes, you're right. But I'm not sure if updating the dependencies will cause other problems or not.

I found that the actual problem is that koa-webpack depends on webpack=^2.3.0, which is not compatible with webpack=^3.0.0. So, when using webpack 3.0, this module will still use webpack 2.3 (in its node_modules). This leads to the issue mentioned above.

Is it safe to change the dependency version to webpack>=2.3?

I got the same error but I just passed my own webpack instance (3.3.*) which fixed it:

import Webpack from 'webpack';
import config from './webpack.config.js';
const compiler = Webpack(config);
app.use(middleware({
  compiler: compiler
}))

Landed in 1.0.0