替代'System.import'

时间:2019-04-30 02:25:37

标签: reactjs react-redux react-router webpack-2 webpack-4

更新Webpack后,System.import开始显示弃用错误。

if (typeof System === 'undefined' || typeof System.import === 
 'undefined') {
 global.System = {};
 System.import = module => Promise.resolve(require(module));

}

下面是loadRoute:

    function loadRoute(routePromise, reducerPromises = null) {
    return () => {
        routePromise = routePromise
            .then(module => (module.default ? module.default : module))
            .catch(err => console.error('Dynamic page loading failed', err));

        if (reducerPromises === null) {
            return routePromise;
        }

        return injectReducerAndRender(reducerPromises, routePromise);
    };
}

路线

<Route                       
 path="configuration/school-setup"
 getComponent={loadRoute(                
 System.import('./modules/Configuration/pages/SchoolSetup/SchoolSetup'),
 )}
/>

1 个答案:

答案 0 :(得分:0)

import('path/...and/some/more/to/get/over/the/character/limit')