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

SSR 的 getManifest()支持req时传入sourceDir表示SSR产物目录 #11715

Merged
merged 13 commits into from
Oct 10, 2023
Merged

SSR 的 getManifest()支持req时传入sourceDir表示SSR产物目录 #11715

merged 13 commits into from
Oct 10, 2023

Conversation

gwuhaolin
Copy link
Member

No description provided.

@vercel
Copy link

vercel bot commented Oct 9, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
umi ⬜️ Ignored (Inspect) Visit Preview Oct 10, 2023 2:13am

@gwuhaolin gwuhaolin changed the title getManifest支持传入sourceDir表示SSR产物目录 SSR 的 getManifest()支持req时传入sourceDir表示SSR产物目录 Oct 9, 2023
@codecov
Copy link

codecov bot commented Oct 9, 2023

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (fb0a75f) 28.93% compared to head (e9ced7f) 28.94%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11715      +/-   ##
==========================================
+ Coverage   28.93%   28.94%   +0.01%     
==========================================
  Files         485      485              
  Lines       14771    14765       -6     
  Branches     3498     3497       -1     
==========================================
  Hits         4274     4274              
+ Misses       9737     9731       -6     
  Partials      760      760              
Files Coverage Δ
packages/server/src/ssr.ts 0.00% <0.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

packages/server/src/ssr.ts Outdated Show resolved Hide resolved
packages/server/src/ssr.ts Show resolved Hide resolved
packages/server/src/ssr.ts Outdated Show resolved Hide resolved
packages/preset-umi/templates/server.tpl Outdated Show resolved Hide resolved
@sorrycc sorrycc merged commit e6e5eef into umijs:master Oct 10, 2023
22 checks passed
@@ -24,6 +24,7 @@ interface CreateRequestHandlerOptions {
helmetContext?: any;
ServerInsertedHTMLContext: React.Context<ServerInsertedHTMLHook | null>;
withoutHTML?: boolean;
sourceDir?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

看起来这里需要注释注明一下 sourceDir 是给 serverless 函数 create handler 专门用的,因为 esbuild 用到的 g_getAssets 没法传 sourceDir

global.g_getAssets = (fileName) => {
  let m = typeof manifest === 'function' ? manifest() : manifest;
  return m.assets[fileName];
};
// 生产环境这里的 manifest 就没有机会传参数了
const manifest = {{{ env }}} === 'development' ? getManifest : getManifest();

// ...
// ↓ 人工 create handler 才可以传 sourceDir
  manifest: getManifest,

Copy link
Contributor

@fz6m fz6m Oct 10, 2023

Choose a reason for hiding this comment

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

interface CreateRequestHandlerServerlessOptions {
  /** 注释 */
  withoutHTML?: boolean;
  /** 注释 */
  sourceDir?: string;
}

interface CreateRequestHandlerOptions extends CreateRequestHandlerServerlessOptions {
  // ...
}

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.

3 participants