Skip to content

Commit

Permalink
fix: reading 'log' error (#157)
Browse files Browse the repository at this point in the history
Co-authored-by: Juan Rodriguez <nushio@gmail.com>
  • Loading branch information
co3k and Nushio authored May 14, 2022
1 parent d10fcf6 commit f855bfb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/files/entry.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
declare module "APP" {
import { App } from "@sveltejs/kit";
export { App };
}

declare module "MANIFEST" {
import { SSRManifest } from "@sveltejs/kit";

export const manifest: SSRManifest;
}
1 change: 1 addition & 0 deletions src/files/entry.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import { Server } from 'SERVER';
import { manifest } from 'MANIFEST';
import { toSvelteKitRequest } from './firebase-to-svelte-kit.js';
Expand Down
2 changes: 1 addition & 1 deletion src/files/firebase-to-svelte-kit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
export function toSvelteKitRequest(request) {
const host = `${request.headers['x-forwarded-proto']}://${request.headers.host}`;
const { href, pathname, searchParams: searchParameters } = new URL(request.url || '', host);
const {href, pathname, searchParams: searchParameters} = new URL(request.url || '', host);

return new Request(href, {
method: request.method,
Expand Down
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const entrypoint = function (options = {}) {
builder.log.minor(`Adapter configuration:\n\t${JSON.stringify(options)}`);
const { functions, publicDir } = parseFirebaseConfiguration({ firebaseJsonPath, target, sourceRewriteMatch });
ensureStaticResourceDirsDiffer({ source: path.join(process.cwd(), builder.getStaticDirectory()), dest: publicDir });

const functionsPackageJson = JSON.parse(readFileSync(path.join(functions.source, 'package.json'), 'utf-8'));
if (!functionsPackageJson?.main) {
throw new Error(`Error reading ${functionsPackageJson}. Required field "main" missing.`);
Expand Down Expand Up @@ -107,6 +106,10 @@ const entrypoint = function (options = {}) {
builder.writeClient(publicDir);

builder.log.minor(logRelativeDir('Prerendering static pages to', publicDir));
const {paths} = await builder.prerender({dest: publicDir});
writeFileSync(`${dirs.tmp}/manifest.js`, `export const manifest = ${builder.generateManifest({
relativePath,
})};\n\nexport const prerendered = new Set(${JSON.stringify(paths)});\n`);
},
};
};
Expand Down

0 comments on commit f855bfb

Please sign in to comment.