React+react-router `require.ensure Error in Loading Server Rendering on Demand

  node.js, question

I tried to use require.ensure to achieve the effect of loading on demand, but because I do server rendering here, now the front end and server share a routing controller:

const routes = {
 component: Shell(Init),
 childRoutes: [
 bracket
 path: 'login',
 getComponent: (nextState, cb) => {
 require.ensure([], (require) => {
 cb(null, require('../containers/login'))
 })
 bracket
 bracket
 bracket
 };

But in the server execution is reported wrong:

TypeError: require.ensure is not a function
 at Object.getComponent (D:/luoo/nodejs/app/routes/routes.jsx:49:25)
 at getComponentsForRoute (D:\luoo\nodejs\node_modules\react-router\lib\getComponents.js:29:16)
 at D:\luoo\nodejs\node_modules\react-router\lib\getComponents.js:41:5
 at D:\luoo\nodejs\node_modules\react-router\lib\AsyncUtils.js:84:5
 at Array.forEach (native)
 at mapAsync (D:\luoo\nodejs\node_modules\react-router\lib\AsyncUtils.js:83:9)
 at getComponents (D:\luoo\nodejs\node_modules\react-router\lib\getComponents.js:40:28)
 at finishEnterHooks (D:\luoo\nodejs\node_modules\react-router\lib\createTransitionManager.js:112:35)
 at runTransitionHooks (D:\luoo\nodejs\node_modules\react-router\lib\TransitionUtils.js:50:5)
 at runEnterHooks (D:\luoo\nodejs\node_modules\react-router\lib\TransitionUtils.js:93:10)

Is there any solution to this problem?

If webpack target is node, require is the require of native node.js, norequire.ensureMethods.

You can write a shim for the server environment