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

Update to latest sveltekit #25

Merged
merged 4 commits into from
Mar 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 polka@1.0.0-next.22 compression@^1.7.4 sirv@^2.0.2
Expand Down