-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: SSR in mode vite ssr #5045
Conversation
Codecov Report
@@ Coverage Diff @@
## release/2.5.0 #5045 +/- ##
=================================================
+ Coverage 30.06% 30.22% +0.15%
=================================================
Files 198 201 +3
Lines 5245 5271 +26
Branches 1279 1286 +7
=================================================
+ Hits 1577 1593 +16
- Misses 3379 3389 +10
Partials 289 289
|
], | ||
"$store": [ | ||
"src/store1.ts" | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
后面两个多余的
@@ -52,7 +52,7 @@ export function runApp(appConfig?: IAppConfig) { | |||
// set History before GID | |||
initHistory && initHistory(appConfig as any); | |||
<% } %> | |||
if (process.env.__IS_SERVER__) return; | |||
if ((typeof global !== 'undefined' && (global as any).__IS_SERVER__) || process.env.__IS_SERVER__) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么不复用 process.env.__IS_SERVER__
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是不是全部统一到运行时判断:globalThis.IS_SERVER
@@ -17,7 +28,7 @@ export default async function ssgRender(options) { | |||
const { path = '', getInitialProps, ...rest } = flatRoute; | |||
|
|||
const keys = []; | |||
pathToRegexp(path, keys); | |||
(pathToRegexp.default || pathToRegexp)(path, keys); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么需要这样判断?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在标准的 esm 规范里面 import * as pathToRegexp from 'path-to-regexp';
被认为是导入的是一个对象,而 import pathToRegexp from 'path-to-regexp';
是默认的方法导出。 webpack 下对上述两种方式进行了兼容,而 vite 模式下不会
Resolve #4651