From 6735a2bcbb733e198a667929632e67e6d2428eaf Mon Sep 17 00:00:00 2001 From: luhc228 Date: Fri, 19 Nov 2021 11:35:21 +0800 Subject: [PATCH 1/6] fix: ssg render error --- examples/with-prerender-spa/src/routes.ts | 1 - packages/plugin-ice-ssr/package.json | 2 +- packages/plugin-ice-ssr/src/renderPages.ts.ejs | 7 +++---- packages/plugin-ice-ssr/src/server.ts.ejs | 2 +- packages/runtime/package.json | 5 +++-- packages/runtime/src/index.ts | 2 ++ yarn.lock | 9 ++++++++- 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/examples/with-prerender-spa/src/routes.ts b/examples/with-prerender-spa/src/routes.ts index 29e8badaaf..f227cfae51 100644 --- a/examples/with-prerender-spa/src/routes.ts +++ b/examples/with-prerender-spa/src/routes.ts @@ -24,7 +24,6 @@ export default [ component: Dashboard }, { - path: '*', component: NotFound, } ]; diff --git a/packages/plugin-ice-ssr/package.json b/packages/plugin-ice-ssr/package.json index 470ab6a146..c0e8894049 100644 --- a/packages/plugin-ice-ssr/package.json +++ b/packages/plugin-ice-ssr/package.json @@ -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" } } \ No newline at end of file diff --git a/packages/plugin-ice-ssr/src/renderPages.ts.ejs b/packages/plugin-ice-ssr/src/renderPages.ts.ejs index e4c3697778..664d438e61 100644 --- a/packages/plugin-ice-ssr/src/renderPages.ts.ejs +++ b/packages/plugin-ice-ssr/src/renderPages.ts.ejs @@ -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; @@ -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) { diff --git a/packages/plugin-ice-ssr/src/server.ts.ejs b/packages/plugin-ice-ssr/src/server.ts.ejs index 3521dbc184..a564bfca25 100644 --- a/packages/plugin-ice-ssr/src/server.ts.ejs +++ b/packages/plugin-ice-ssr/src/server.ts.ejs @@ -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'; diff --git a/packages/runtime/package.json b/packages/runtime/package.json index 3c2985cae8..0405ad20a1 100644 --- a/packages/runtime/package.json +++ b/packages/runtime/package.json @@ -1,6 +1,6 @@ { "name": "@ice/runtime", - "version": "0.1.0", + "version": "0.1.1-beta.0", "description": "runtime dependencies for plugin runtime", "main": "lib/index.js", "scripts": { @@ -13,6 +13,7 @@ "author": "", "license": "ISC", "dependencies": { - "axios": "^0.21.4" + "axios": "^0.21.4", + "path-to-regexp": "^1.8.0" } } diff --git a/packages/runtime/src/index.ts b/packages/runtime/src/index.ts index 518c7ade2f..e098f56b1e 100644 --- a/packages/runtime/src/index.ts +++ b/packages/runtime/src/index.ts @@ -1,7 +1,9 @@ import axios from 'axios'; +import * as pathToRegexp from 'path-to-regexp'; import axiosUtils from './axiosUtils'; export { axios, axiosUtils, + pathToRegexp }; \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index e5dd4b8d9e..40081b4ce7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1562,6 +1562,13 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45" integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== +"@ice/runtime@^0.1.0": + version "0.1.0" + resolved "https://registry.yarnpkg.com/@ice/runtime/-/runtime-0.1.0.tgz#f63f59f4393f6f8637f791d57925ebf17d295c40" + integrity sha512-pmGc2OQz/fTSsv8RLJr1QMFPG+XP194U/D6ZG0pfvkbxgLkmxoDs+PR6yFU8LxYkV4/YWOPJrCtHoa9omyuJKA== + dependencies: + axios "^0.21.4" + "@ice/sandbox@^1.0.4": version "1.1.3" resolved "https://registry.yarnpkg.com/@ice/sandbox/-/sandbox-1.1.3.tgz#7886afbda4c75df5caf624619575fa69c4289e09" @@ -12935,7 +12942,7 @@ path-to-regexp@0.1.7: 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== From 0c60375dbfe4e1ce0eecaac45bddb2c1f91c17f9 Mon Sep 17 00:00:00 2001 From: luhc228 Date: Fri, 19 Nov 2021 14:41:44 +0800 Subject: [PATCH 2/6] chore: version and changelog --- packages/icejs/package.json | 2 +- packages/plugin-ice-ssr/CHANGELOG.md | 7 ++++++- packages/plugin-ice-ssr/package.json | 2 +- packages/runtime/CHANGELOG.md | 4 ++++ packages/runtime/package.json | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/icejs/package.json b/packages/icejs/package.json index 69e1ad0a10..348cb88b8b 100644 --- a/packages/icejs/package.json +++ b/packages/icejs/package.json @@ -32,7 +32,7 @@ "build-plugin-ice-mpa": "2.0.1", "build-plugin-ice-request": "2.0.0", "build-plugin-ice-router": "2.0.2", - "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", diff --git a/packages/plugin-ice-ssr/CHANGELOG.md b/packages/plugin-ice-ssr/CHANGELOG.md index 3a36937e89..c58bce88aa 100644 --- a/packages/plugin-ice-ssr/CHANGELOG.md +++ b/packages/plugin-ice-ssr/CHANGELOG.md @@ -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 diff --git a/packages/plugin-ice-ssr/package.json b/packages/plugin-ice-ssr/package.json index c0e8894049..2b36a473f8 100644 --- a/packages/plugin-ice-ssr/package.json +++ b/packages/plugin-ice-ssr/package.json @@ -1,6 +1,6 @@ { "name": "build-plugin-ice-ssr", - "version": "3.0.2", + "version": "3.0.3", "description": "ssr plugin", "author": "ice-admin@alibaba-inc.com", "homepage": "", diff --git a/packages/runtime/CHANGELOG.md b/packages/runtime/CHANGELOG.md index 2445cc45c8..8236984ea3 100644 --- a/packages/runtime/CHANGELOG.md +++ b/packages/runtime/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.1.1 + +- [feat] add `path-to-regexp@1.x` dependency + ## 0.1.0 - [feat] dependency of axios and utils for axios \ No newline at end of file diff --git a/packages/runtime/package.json b/packages/runtime/package.json index 0405ad20a1..ba4a849ef8 100644 --- a/packages/runtime/package.json +++ b/packages/runtime/package.json @@ -1,6 +1,6 @@ { "name": "@ice/runtime", - "version": "0.1.1-beta.0", + "version": "0.1.1", "description": "runtime dependencies for plugin runtime", "main": "lib/index.js", "scripts": { From cb0f2bb98fa3e1b11204f008137f9fa50316dba0 Mon Sep 17 00:00:00 2001 From: luhc228 Date: Tue, 23 Nov 2021 14:34:29 +0800 Subject: [PATCH 3/6] chore: icejs version --- packages/icejs/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/icejs/package.json b/packages/icejs/package.json index 2c0ee30413..f8a140ca19 100644 --- a/packages/icejs/package.json +++ b/packages/icejs/package.json @@ -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": "ice-admin@alibaba-inc.com", "homepage": "", From 045f54cf20bef2d2ef493bf6c976b7640fe5d6ee Mon Sep 17 00:00:00 2001 From: luhc228 Date: Tue, 23 Nov 2021 14:36:35 +0800 Subject: [PATCH 4/6] chore: example routes --- examples/with-prerender-spa/src/routes.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/with-prerender-spa/src/routes.ts b/examples/with-prerender-spa/src/routes.ts index f227cfae51..29e8badaaf 100644 --- a/examples/with-prerender-spa/src/routes.ts +++ b/examples/with-prerender-spa/src/routes.ts @@ -24,6 +24,7 @@ export default [ component: Dashboard }, { + path: '*', component: NotFound, } ]; From 1b5c693e7ac7011bf18591f808bde8a7257fda84 Mon Sep 17 00:00:00 2001 From: luhc228 Date: Tue, 23 Nov 2021 14:38:18 +0800 Subject: [PATCH 5/6] chore: add sideEffects as false to @ice/runtime --- packages/runtime/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/runtime/package.json b/packages/runtime/package.json index ba4a849ef8..7bad6be6ad 100644 --- a/packages/runtime/package.json +++ b/packages/runtime/package.json @@ -15,5 +15,6 @@ "dependencies": { "axios": "^0.21.4", "path-to-regexp": "^1.8.0" - } + }, + "sideEffects": false } From a397d9eb129cd7fb1c6bc81869877453480d8ebc Mon Sep 17 00:00:00 2001 From: luhc228 Date: Tue, 23 Nov 2021 14:52:16 +0800 Subject: [PATCH 6/6] chore: update yarn.lock --- yarn.lock | 7 ------- 1 file changed, 7 deletions(-) diff --git a/yarn.lock b/yarn.lock index 5281f867c5..99818dc93b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1562,13 +1562,6 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45" integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== -"@ice/runtime@^0.1.0": - version "0.1.0" - resolved "https://registry.yarnpkg.com/@ice/runtime/-/runtime-0.1.0.tgz#f63f59f4393f6f8637f791d57925ebf17d295c40" - integrity sha512-pmGc2OQz/fTSsv8RLJr1QMFPG+XP194U/D6ZG0pfvkbxgLkmxoDs+PR6yFU8LxYkV4/YWOPJrCtHoa9omyuJKA== - dependencies: - axios "^0.21.4" - "@ice/sandbox@^1.0.4": version "1.1.3" resolved "https://registry.yarnpkg.com/@ice/sandbox/-/sandbox-1.1.3.tgz#7886afbda4c75df5caf624619575fa69c4289e09"