Skip to content
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

Merged
merged 27 commits into from Jan 11, 2022
Merged

feat: SSR in mode vite ssr #5045

merged 27 commits into from Jan 11, 2022

Conversation

ClarkXia
Copy link
Collaborator

@ClarkXia ClarkXia commented Dec 15, 2021

Resolve #4651

  • support ssr when dev
  • bundle server.js for node
  • support ssg in vite

@codecov-commenter
Copy link

codecov-commenter commented Dec 15, 2021

Codecov Report

Merging #5045 (dc14537) into release/2.5.0 (7f4faad) will increase coverage by 0.15%.
The diff coverage is 55.10%.

Impacted file tree graph

@@                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              
Impacted Files Coverage Δ
packages/plugin-ice-ssr/src/env.ts 0.00% <0.00%> (ø)
packages/plugin-react-app/src/runtime.tsx 0.00% <0.00%> (ø)
packages/plugin-router/src/runtime.tsx 0.00% <0.00%> (ø)
packages/react-app-renderer/src/renderer.tsx 0.00% <0.00%> (ø)
packages/react-app-renderer/src/server.tsx 0.00% <0.00%> (ø)
packages/vite-service/src/build.ts 0.00% <0.00%> (ø)
packages/plugin-ice-ssr/src/index.ts 54.47% <65.21%> (+0.16%) ⬆️
packages/runtime/src/env.ts 75.00% <75.00%> (ø)
packages/plugin-ice-ssr/src/replaceHtmlContent.ts 100.00% <100.00%> (ø)

@ClarkXia ClarkXia changed the title [WIP] SSR in mode vite ssr feat: SSR in mode vite ssr Dec 20, 2021
@ClarkXia ClarkXia changed the base branch from release-next to release/2.5.0 December 29, 2021 11:18
@luhc228 luhc228 self-requested a review January 6, 2022 02:39
],
"$store": [
"src/store1.ts"
]
Copy link
Collaborator

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么不复用 process.env.__IS_SERVER__

Copy link
Collaborator

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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么需要这样判断?

Copy link
Collaborator Author

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 模式下不会

packages/plugin-ice-ssr/src/index.ts Show resolved Hide resolved
packages/plugin-ice-ssr/src/vite/ssrPlugin.ts Show resolved Hide resolved
packages/plugin-ice-ssr/src/vite/ssrPlugin.ts Show resolved Hide resolved
packages/plugin-ice-ssr/src/vite/ssrPlugin.ts Outdated Show resolved Hide resolved
@CLAassistant
Copy link

CLAassistant commented Jan 10, 2022

CLA assistant check
All committers have signed the CLA.

@imsobear imsobear merged commit 723a8b7 into release/2.5.0 Jan 11, 2022
@imsobear imsobear deleted the feat-vite-ssr branch January 11, 2022 02:36
@ClarkXia ClarkXia mentioned this pull request Jan 11, 2022
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants