是否有可能实现嵌套异步路由获取,System.import
因此应用程序仅分为几个合理的块,而不是许多小块?
背景
我正在我的 React 应用程序中实现捆绑拆分。最初我实现了 bundle-loader(我无法在所有情况下都开始工作),然后使用 System.import,我发现它的行为更加可预测。
问题
代码拆分在逐个路由的基础上工作得很好,但是,它会产生许多小包,并且额外的包和获取的开销是不必要的和浪费的。
例如,我有这段代码,当您导航到他们的页面时,它会为仪表板、设置或图像加载包:
<Provider store={store}>
<Router history={browserHistory}>
<Route path='/' component={Container}>
<IndexRedirect to="Login" />
<Route path='Registration' component={RegistrationContainer} />
<Route path='Login' component={LoginContainer} />
<Route path='Route1' >
<IndexRedirect to="Dashboard" />
<Route path='Settings'
getComponent={ (loc, cb)=> {System.import('./components/Route1/Settings')
.then(loadRoute(cb))
.catch(errorLoading); }}/>
<Route path='Dashboard'
getComponent={ (loc, cb)=> {System.import('./components/Route1/Dashboard')
.then(loadRoute(cb))
.catch(errorLoading); }}
/>
<Route path='Images'
getComponent={ (loc, cb)=> {System.import('./components/Route1/Images')
.then(loadRoute(cb))
.catch(errorLoading); }}
/>
</Router>
</Provider>
首次导航到 Route1 路径时,是否可以为所有三个加载捆绑包?
非常感谢