fix: can not get the getStaticPaths method (#5325)

This commit is contained in:
luhc228 2022-06-08 10:18:00 +08:00 committed by GitHub
parent 789e3f8acc
commit f7512ce022
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 5 deletions

View File

@ -1,7 +1,9 @@
import { lazy } from 'ice';
import Home from '@/pages/Home';
import About from '@/pages/About';
import Dashboard from '@/pages/Dashboard';
import NotFound from '@/pages/NotFound';
import Dashboard from '@/pages/Dashboard';
const About = lazy(() => import('@/pages/About'));
export default [
{

View File

@ -32,7 +32,7 @@
"build-plugin-ice-mpa": "2.1.1",
"build-plugin-ice-request": "2.0.0",
"build-plugin-ice-router": "2.1.3",
"build-plugin-ice-ssr": "3.1.2",
"build-plugin-ice-ssr": "3.1.3",
"build-plugin-ice-store": "2.0.7",
"build-plugin-react-app": "2.2.2",
"build-plugin-pwa": "1.1.1",

View File

@ -1,5 +1,9 @@
# Changelog
## 3.1.3
- [fix] can't get the getStaticPaths method from the dynamic import route component
## 3.1.2
- [feat] support generate defaultLocale HTML in SSG

View File

@ -1,6 +1,6 @@
{
"name": "build-plugin-ice-ssr",
"version": "3.1.2",
"version": "3.1.3",
"description": "ssr plugin",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",

View File

@ -73,7 +73,13 @@ async function getFlatRoutes(routes, parentPath = '') {
route.component = loadable(route.component.dynamicImport);
}
prev.push(route);
const getStaticPaths = route.getStaticPaths || route.component.getStaticPaths;
// normal import component
let getStaticPaths = route.getStaticPaths || route.component.getStaticPaths;
if (route.component.load) {
// dynamic import component
const loadedPageComponent = await route.component.load();
getStaticPaths = (loadedPageComponent.default || loadedPageComponent).getStaticPaths;
}
if (typeof getStaticPaths === 'function') {
const staticPaths = await getStaticPaths();
if (Array.isArray(staticPaths)) {