mirror of https://github.com/alibaba/ice.git
feat: support custom props when render document (#7099)
CI / build (16.x, ubuntu-latest) (push) Waiting to run
Details
CI / build (16.x, windows-latest) (push) Waiting to run
Details
CI / build (18.x, ubuntu-latest) (push) Waiting to run
Details
CI / build (18.x, windows-latest) (push) Waiting to run
Details
Coverage / coverage (16.x) (push) Waiting to run
Details
Release / Release (16) (push) Waiting to run
Details
CI / build (16.x, ubuntu-latest) (push) Waiting to run
Details
CI / build (16.x, windows-latest) (push) Waiting to run
Details
CI / build (18.x, ubuntu-latest) (push) Waiting to run
Details
CI / build (18.x, windows-latest) (push) Waiting to run
Details
Coverage / coverage (16.x) (push) Waiting to run
Details
Release / Release (16) (push) Waiting to run
Details
* feat: support custom props when render document * Update packages/runtime/src/types.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update packages/runtime/src/renderDocument.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: test case * Update runServerApp.tsx * fix: optimize props * chore: optimize code --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
80250ffe6e
commit
cc0792b0fd
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@ice/runtime': patch
|
||||
---
|
||||
|
||||
feat: support custom props when render document
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@ice/app': patch
|
||||
---
|
||||
|
||||
fix: minify server bundle when build in prod
|
|
@ -184,6 +184,7 @@ export function createServerCompiler(options: Options) {
|
|||
// while it is not recommended
|
||||
loader: { '.js': 'jsx' },
|
||||
jsx: 'automatic',
|
||||
minify: !dev,
|
||||
sourcemap: typeof sourceMap === 'boolean'
|
||||
// Transform sourceMap for esbuild.
|
||||
? sourceMap : (sourceMap.includes('inline') ? 'inline' : !!sourceMap),
|
||||
|
|
|
@ -59,6 +59,7 @@ interface RenderOptions {
|
|||
publicPath?: string;
|
||||
serverData?: any;
|
||||
streamOptions?: RenderToPipeableStreamOptions;
|
||||
documentProps?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export async function renderToHTML(requestContext, options: RenderOptions = {}) {
|
||||
|
|
|
@ -45,6 +45,7 @@ export function renderDocument(options: RenderDocumentOptions): Response {
|
|||
basename,
|
||||
routesConfig = {},
|
||||
serverData,
|
||||
documentProps,
|
||||
} = renderOptions;
|
||||
|
||||
const appData = null;
|
||||
|
@ -84,7 +85,7 @@ export function renderDocument(options: RenderDocumentOptions): Response {
|
|||
<AppContextProvider value={appContext}>
|
||||
<DocumentContextProvider value={documentContext}>
|
||||
{
|
||||
Document && <Document pagePath={routePath} />
|
||||
Document && <Document pagePath={routePath} {...documentProps} />
|
||||
}
|
||||
</DocumentContextProvider>
|
||||
</AppContextProvider>,
|
||||
|
|
|
@ -283,7 +283,7 @@ async function renderServerEntry(
|
|||
renderOptions,
|
||||
}: RenderServerEntry,
|
||||
): Promise<Response> {
|
||||
const { Document } = renderOptions;
|
||||
const { Document, documentProps } = renderOptions;
|
||||
const appContext = runtime.getAppContext();
|
||||
const { routes, routePath, loaderData, basename } = appContext;
|
||||
const AppRuntimeProvider = runtime.composeAppProvider() || React.Fragment;
|
||||
|
@ -307,7 +307,7 @@ async function renderServerEntry(
|
|||
<AppRuntimeProvider>
|
||||
<DocumentContextProvider value={documentContext}>
|
||||
{
|
||||
Document && <Document pagePath={routePath} />
|
||||
Document && <Document pagePath={routePath} {...documentProps} />
|
||||
}
|
||||
</DocumentContextProvider>
|
||||
</AppRuntimeProvider>
|
||||
|
|
|
@ -338,6 +338,7 @@ export interface RenderOptions {
|
|||
runtimeOptions?: Record<string, any>;
|
||||
serverData?: any;
|
||||
streamOptions?: RenderToPipeableStreamOptions;
|
||||
documentProps?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
|
|
@ -20,7 +20,7 @@ describe(`build ${example}`, () => {
|
|||
sizeFallback = fs.statSync(fallbackPath).size;
|
||||
|
||||
expect(sizeFallback).toBeLessThan(sizeServer);
|
||||
// The Stat size of fallback entry will reduce more than 50kb.
|
||||
expect(sizeServer - sizeFallback).toBeGreaterThan(50 * 1024);
|
||||
// The Stat size of fallback entry will reduce more than 50kb, minify size is 20kb.
|
||||
expect(sizeServer - sizeFallback).toBeGreaterThan(20 * 1024);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue