Uncaught TypeError: require.ensure is not a function at Object.getComponent (ECMASCRIPT)

Uncaught TypeError: require.ensure is not a function at Object.getComponent (ECMASCRIPT)

我正在移植我的 meteor 项目以使用 ecmascript 而不是使用 webpack / babel。同时升级我的流星(从 1.4 到 1.7)并做出反应(从 15.3.2 到 16.8.6)。

routes.jsx

import * as React from 'react';

export default function (injectDeps, {Store, Routes}) {
  const route = {
    path: 'tickets',
    onEnter: (nextState, replace) => {
      if (!Meteor.userId() || !Roles.userIsInRole(Meteor.userId(), 'staff', Roles.GLOBAL_GROUP)) {
        replace('/login');
      }
    },
    getComponent(nextState, cb) {
      require.ensure([], (require) => {
        Store.injectReducer('tickets', require('./reducers'));
        cb(null, require('./containers/list.js'));
      }, 'tickets');
    },
    childRoutes: [
      {
        path: ':_id',
        getComponent(nextState, cb) {
          require.ensure([], (require) => {
            Store.injectReducer('tickets', require('./reducers'));
            cb(null, require('./containers/view.js'));
          }, 'tickets.view');
        }
      }
    ]
  };

  Routes.injectChildRoute(route);
}

Got this error:

Uncaught TypeError: require.ensure is not a function
    at Object.getComponent (routes.jsx:20)
    at getComponentsForRoute (modules.js?hash=d04d5856a2fe2fa5c3dc6837e85d41adc321ecb2:38035)
    at modules.js?hash=d04d5856a2fe2fa5c3dc6837e85d41adc321ecb2:38053
    at modules.js?hash=d04d5856a2fe2fa5c3dc6837e85d41adc321ecb2:37842
    at Array.forEach (<anonymous>)
    at mapAsync (modules.js?hash=d04d5856a2fe2fa5c3dc6837e85d41adc321ecb2:37841)
    at getComponents (modules.js?hash=d04d5856a2fe2fa5c3dc6837e85d41adc321ecb2:38052)
    at finishEnterHooks (modules.js?hash=d04d5856a2fe2fa5c3dc6837e85d41adc321ecb2:37263)
    at next (modules.js?hash=d04d5856a2fe2fa5c3dc6837e85d41adc321ecb2:37810)
    at loopAsync (modules.js?hash=d04d5856a2fe2fa5c3dc6837e85d41adc321ecb2:37814

有什么移植的建议吗?

这是摆脱require.ensure的方法:

routes.jsx(最终)

{
    path: 'config',
    getComponent(nextState, cb) {
        import('./containers/config').then(mod => {
            Store.injectReducer('config', require('./reducers/config').default);
            cb(null, mod.default);
        });
    }
}

注意: 1) 这就是如何从 require.ensure(由 webpack 使用)迁移到不依赖 webpack(这是我的情况,因为我完全使用 Meteor Atmosphere 到 运行) 2) 如果 reducer 函数导出为 export defaultmodrequire(...).xxx 已更改为 mod.defaultrequire(...).default,否则表示 reducer不会被调用。