Skip to content

Commit

Permalink
[feat] Allow transformPage to return a promise (#4036)
Browse files Browse the repository at this point in the history
* allow transformPage to return a promise

* add changeset
  • Loading branch information
JeanJPNM authored Feb 21, 2022
1 parent 74d197d commit 1264c46
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/forty-seahorses-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Allow the `transformPage` resolve option to return a promise
2 changes: 1 addition & 1 deletion packages/kit/src/runtime/server/page/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ export async function render_response({
const assets =
options.paths.assets || (segments.length > 0 ? segments.map(() => '..').join('/') : '.');

const html = resolve_opts.transformPage({
const html = await resolve_opts.transformPage({
html: options.template({ head, body, assets, nonce: /** @type {string} */ (csp.nonce) })
});

Expand Down
2 changes: 1 addition & 1 deletion packages/kit/types/internal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export type RecursiveRequired<T> = {

export interface RequiredResolveOptions {
ssr: boolean;
transformPage: ({ html }: { html: string }) => string;
transformPage: ({ html }: { html: string }) => MaybePromise<string>;
}

export interface Respond {
Expand Down

0 comments on commit 1264c46

Please sign in to comment.