Skip to content

Commit

Permalink
Merge pull request #25 from HalfdanJ/pullrequests/abynim/update-fetch…
Browse files Browse the repository at this point in the history
…-polyfil

Update to latest sveltekit
  • Loading branch information
HalfdanJ authored Mar 26, 2022
2 parents 917402a + 885b03d commit d30e1a5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
5 changes: 2 additions & 3 deletions files/entry.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import path from 'node:path';
// eslint-disable-next-line camelcase
import {__fetch_polyfill} from '@sveltejs/kit/install-fetch';
import {installFetch} from '@sveltejs/kit/install-fetch';
import {getRequest, setResponse} from '@sveltejs/kit/node';
import compression from 'compression';
import {manifest} from 'MANIFEST';
import polka from 'polka';
import sirv from 'sirv';
import {Server} from 'SERVER';

__fetch_polyfill();
installFetch();

const app = new Server(manifest);

Expand Down
12 changes: 5 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ export default function entrypoint() {
const relativePath = posix.relative(temporary, builder.getServerDirectory());

builder.log.minor('Prerendering static pages');
const prerenderedPaths = await builder.prerender({
dest: `${dir}/storage`,
});
builder.writePrerendered(`${dir}/storage`);

// Copy server handler
builder.copy(files, temporary, {replace: {
Expand All @@ -53,14 +51,14 @@ export default function entrypoint() {

writeFileSync(`${dir}/package.json`, JSON.stringify({type: 'commonjs'}));

const prerenderedPages = Array.from(prerenderedPaths.pages, ([src, page]) => ({
const prerenderedPages = Array.from(builder.prerendered.pages, ([src, page]) => ({
url: src + '/?$',
// eslint-disable-next-line camelcase
static_files: 'storage/' + page.file,
upload: 'storage/' + page.file,
}));

const prerenderedRedirects = Array.from(prerenderedPaths.redirects, ([src, _]) => ({
const prerenderedRedirects = Array.from(builder.prerendered.redirects, ([src, _]) => ({
url: src,
secure: 'always',
script: 'auto',
Expand All @@ -78,9 +76,9 @@ export default function entrypoint() {
...prerenderedPages,
...prerenderedRedirects,
{
url: `/${builder.appDir}/`,
url: `/${builder.config.kit.appDir}/`,
// eslint-disable-next-line camelcase
static_dir: `storage/${builder.appDir}`,
static_dir: `storage/${builder.config.kit.appDir}`,
expiration: '30d 0h',
},
{
Expand Down
2 changes: 1 addition & 1 deletion tests/expected_app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ handlers:
- url: /about/?$
static_files: storage/about.html
upload: storage/about.html
- url: /_app/.+
- url: /_app/
static_dir: storage/_app
expiration: 30d 0h
- url: /.*
Expand Down
2 changes: 1 addition & 1 deletion tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ pushd $TEST_DIR

set -e

npm i
npm i "${SCRIPT_PATH}/../"
npm i

# These are peer dependencies that need manual install since we install from folder instead of from npm registry
npm install [email protected] compression@^1.7.4 sirv@^2.0.2
Expand Down

0 comments on commit d30e1a5

Please sign in to comment.