Skip to content

Commit

Permalink
Merge pull request #4948 from alibaba/fix/ssg-render-error
Browse files Browse the repository at this point in the history
fix: ssg render error
  • Loading branch information
luhc228 authored Nov 23, 2021
2 parents d329e2d + 3027bf4 commit f9ab033
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 14 deletions.
4 changes: 2 additions & 2 deletions packages/icejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ice.js",
"version": "2.2.1",
"version": "2.2.2",
"description": "command line interface and builtin plugin for icejs",
"author": "[email protected]",
"homepage": "",
Expand Down Expand Up @@ -32,7 +32,7 @@
"build-plugin-ice-mpa": "2.0.1",
"build-plugin-ice-request": "2.0.0",
"build-plugin-ice-router": "2.0.3",
"build-plugin-ice-ssr": "3.0.2",
"build-plugin-ice-ssr": "3.0.3",
"build-plugin-ice-store": "2.0.5",
"build-plugin-react-app": "2.0.4",
"build-plugin-pwa": "1.0.1",
Expand Down
7 changes: 6 additions & 1 deletion packages/plugin-ice-ssr/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# Changelog

## 3.0.3

- [fix] route path value may be undefined
- [fix] `path-to-regexp` dependency may not be correct for the dependencies promotion

## 3.0.2

- [fix] ssr can't work when using promissory routes
- [fix] ssr can't work when using file-system routes

## 3.0.1

Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-ice-ssr/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-plugin-ice-ssr",
"version": "3.0.2",
"version": "3.0.3",
"description": "ssr plugin",
"author": "[email protected]",
"homepage": "",
Expand Down Expand Up @@ -32,7 +32,7 @@
"fs-extra": "^8.1.0",
"html-minifier": "^4.0.0",
"parseurl": "^1.3.3",
"path-to-regexp": "^1.7.0",
"@ice/runtime": "^0.1.0",
"query-string": "^6.13.7"
}
}
7 changes: 3 additions & 4 deletions packages/plugin-ice-ssr/src/renderPages.ts.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import '@/app';
import { join } from 'path';
import routes from '<%- routesPath %>/routes';
import loadable from '@loadable/component';
import * as pathToRegexp from 'path-to-regexp';

const { renderStatic } = require('./server');
import { pathToRegexp } from '@ice/runtime';
import { renderStatic } from './server';

export default async function ssgRender(options) {
const { htmlTemplate } = options;
Expand Down Expand Up @@ -38,7 +37,7 @@ export default async function ssgRender(options) {
async function getFlatRoutes(routes, parentPath = '') {
return await routes.reduce(async (asyncPrev, route) => {
let prev = await asyncPrev;
const { children, path: currentPath, redirect } = route;
const { children, path: currentPath = '', redirect } = route;
if (children) {
prev = prev.concat(await getFlatRoutes(children, currentPath));
} else if (!redirect) {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-ice-ssr/src/server.ts.ejs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '@/app';
import { join } from 'path';
import * as pathToRegexp from 'path-to-regexp';
import { pathToRegexp } from '@ice/runtime';
import * as cheerio from 'cheerio';
import * as queryString from 'query-string';
import { Helmet } from 'react-helmet';
Expand Down
4 changes: 4 additions & 0 deletions packages/runtime/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.1.1

- [feat] add `[email protected]` dependency

## 0.1.0

- [feat] dependency of axios and utils for axios
8 changes: 5 additions & 3 deletions packages/runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ice/runtime",
"version": "0.1.0",
"version": "0.1.1",
"description": "runtime dependencies for plugin runtime",
"main": "lib/index.js",
"scripts": {
Expand All @@ -13,6 +13,8 @@
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.21.4"
}
"axios": "^0.21.4",
"path-to-regexp": "^1.8.0"
},
"sideEffects": false
}
2 changes: 2 additions & 0 deletions packages/runtime/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import axios from 'axios';
import * as pathToRegexp from 'path-to-regexp';
import axiosUtils from './axiosUtils';

export {
axios,
axiosUtils,
pathToRegexp
};
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12935,7 +12935,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c"
integrity sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=

path-to-regexp@^1.7.0:
path-to-regexp@^1.7.0, path-to-regexp@^1.8.0:
version "1.8.0"
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.8.0.tgz#887b3ba9d84393e87a0a0b9f4cb756198b53548a"
integrity sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==
Expand Down

0 comments on commit f9ab033

Please sign in to comment.