You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#!/usr/bin/env node
console.log('start babel env ...')require('babel-polyfill')require('babel-core/register')console.log('Waiting for webpacking ...')varKoa=require('koa')varapp=newKoa();var{ devMiddleware, hotMiddleware }=require('koa-webpack-middleware')varchokidar=require('chokidar')varwebpack=require('webpack')varwebpackConfig=require('../webpack.config')varpath=require('path')var{ getPortPromise }=require('portfinder')varapplyMiddlewares=require('../src/server/applyMiddlewares').default;varcompiler=webpack(webpackConfig);app.use(devMiddleware(compiler,{noInfo: true,watchOptions: {aggregateTimeout: 300,poll: true},publicPath: '/build/',stats: {colors: true},serverSideRender: true}));app.use(hotMiddleware(compiler,{log: console.log,path: '/__webpack_hmr',heartbeat: 10*1000}));applyMiddlewares(app);app.use((ctx,next)=>{constassetsByChunkName=ctx.res.locals.webpackStats.toJson().assetsByChunkNameconsole.log(assetsByChunkName.compilation.Compilation.inputFileSystem)// then use `assetsByChunkName` for server-sider rendering})app.on('error',function(err,ctx){console.log('error occured:',err.stack)})varserver=require('http').createServer(app.callback())varwatcher=chokidar.watch([path.join(__dirname,'../src/server')])watcher.on('ready',function(){watcher.on('all',function(e,p){console.log("Clearing module cache");Object.keys(require.cache).forEach(function(id){if(/[\/\\](server)[\/\\]/.test(id))deleterequire.cache[id];});})})varisListened=falsecompiler.plugin("emit",function(compilation,callback){callback()if(!isListened){getPortPromise().then(port=>server.listen(port,function(){console.log('App started, at port %d',port)isListened=true}),(err)=>{console.log('Could not get a free port',err);process.exit(-1);})}});
Expected Behavior
I want to get assetsByChunkName.
Actual Behavior
error occured: TypeError: Cannot set property 'webpackStats' of undefined
at /Users/xiongjie/Documents/GitHub/react_isomorphism/node_modules/webpack-dev-middleware/middleware.js:30:30
at Object.ready (/Users/xiongjie/Documents/GitHub/react_isomorphism/node_modules/webpack-dev-middleware/lib/Shared.js:166:29)
at /Users/xiongjie/Documents/GitHub/react_isomorphism/node_modules/webpack-dev-middleware/middleware.js:29:12
at Promise ()
at goNext (/Users/xiongjie/Documents/GitHub/react_isomorphism/node_modules/webpack-dev-middleware/middleware.js:28:11)
at webpackDevMiddleware (/Users/xiongjie/Documents/GitHub/react_isomorphism/node_modules/webpack-dev-middleware/middleware.js:41:33)
at _callee$ (/Users/xiongjie/Documents/GitHub/react_isomorphism/node_modules/koa-webpack-middleware/lib/devMiddleware.js:23:22)
at tryCatch (/Users/xiongjie/Documents/GitHub/react_isomorphism/node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (/Users/xiongjie/Documents/GitHub/react_isomorphism/node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (/Users/xiongjie/Documents/GitHub/react_isomorphism/node_modules/regenerator-runtime/runtime.js:117:21)
The text was updated successfully, but these errors were encountered:
Code
Expected Behavior
I want to get assetsByChunkName.
Actual Behavior
error occured: TypeError: Cannot set property 'webpackStats' of undefined
at /Users/xiongjie/Documents/GitHub/react_isomorphism/node_modules/webpack-dev-middleware/middleware.js:30:30
at Object.ready (/Users/xiongjie/Documents/GitHub/react_isomorphism/node_modules/webpack-dev-middleware/lib/Shared.js:166:29)
at /Users/xiongjie/Documents/GitHub/react_isomorphism/node_modules/webpack-dev-middleware/middleware.js:29:12
at Promise ()
at goNext (/Users/xiongjie/Documents/GitHub/react_isomorphism/node_modules/webpack-dev-middleware/middleware.js:28:11)
at webpackDevMiddleware (/Users/xiongjie/Documents/GitHub/react_isomorphism/node_modules/webpack-dev-middleware/middleware.js:41:33)
at _callee$ (/Users/xiongjie/Documents/GitHub/react_isomorphism/node_modules/koa-webpack-middleware/lib/devMiddleware.js:23:22)
at tryCatch (/Users/xiongjie/Documents/GitHub/react_isomorphism/node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (/Users/xiongjie/Documents/GitHub/react_isomorphism/node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (/Users/xiongjie/Documents/GitHub/react_isomorphism/node_modules/regenerator-runtime/runtime.js:117:21)
The text was updated successfully, but these errors were encountered: