Skip to content

Commit

Permalink
fix: next.282 -> next.292
Browse files Browse the repository at this point in the history
  • Loading branch information
juranki committed Mar 6, 2022
1 parent 5706321 commit 2cdd82b
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 272 deletions.
5 changes: 5 additions & 0 deletions .changeset/late-chefs-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sveltekit-cdk/adapter": patch
---

adjust to adapter changes (1.0.0-next.282 -> 1.0.0-next.292)
4 changes: 2 additions & 2 deletions packages/adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
],
"author": "juhani@juranki.com",
"devDependencies": {
"@sveltejs/kit": "1.0.0-next.282",
"@sveltejs/kit": "1.0.0-next.292",
"@types/aws-lambda": "^8.10.92",
"@types/node": "10.17.27",
"rimraf": "^3.0.2",
"typescript": "^4.5.5"
},
"dependencies": {
"esbuild": "^0.13.9"
"esbuild": "^0.14.25"
}
}
3 changes: 2 additions & 1 deletion packages/adapter/shims.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { fetch, Response, Request, Headers } from '@sveltejs/kit/install-fetch';
import { installFetch } from '@sveltejs/kit/install-fetch';
installFetch()
21 changes: 13 additions & 8 deletions packages/adapter/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,17 @@ export function AwsServerlessAdapter({
builder.rimraf(targetPath)
builder.rimraf(builder.getBuildDirectory('cdk'))

const prerendered = await builder.prerender({
dest: dirs.prerendered,
});
const prerendered = builder.writePrerendered(dirs.prerendered)
const clientfiles = builder.writeClient(dirs.static)
const staticfiles = builder.writeStatic(dirs.static)

// get the routes of prerendered pages
const prerenderedRoutes = prerendered.map(
f => `/${f.replace(/^index.html$/, '').replace(/\/index.html$/, '').replace(/.html$/, '')}`
)
writeFileSync(
path.join(targetPath, 'prerendered.json'),
JSON.stringify(prerendered),
JSON.stringify(prerenderedRoutes),
)
writeFileSync(
path.join(targetPath, 'client.json'),
Expand All @@ -78,7 +80,7 @@ export function AwsServerlessAdapter({
)
writeRoutes(
path.join(targetPath, 'routes.json'),
prerendered.paths, staticfiles, clientfiles
prerendered, staticfiles, clientfiles
)
mkdirSync(builder.getBuildDirectory('cdk'), { recursive: true })
const copiedFiles = builder.copy(files, builder.getBuildDirectory('cdk'), {
Expand All @@ -88,7 +90,10 @@ export function AwsServerlessAdapter({
PRERENDERED: './prerendered',
}
})
writePrerenderedTs(path.join(builder.getBuildDirectory('cdk'), 'prerendered.ts'), prerendered.paths, builder.trailingSlash === 'always')
writePrerenderedTs(
path.join(builder.getBuildDirectory('cdk'), 'prerendered.ts'),
prerenderedRoutes, builder.config.kit.trailingSlash === 'always',
)
await build({
entryPoints: [path.join(builder.getBuildDirectory('cdk'), 'at-edge-handler.js')],
outfile: path.join(dirs.lambda, 'at-edge/handler.js'),
Expand All @@ -111,10 +116,10 @@ function writeRoutes(path: string, pre: string[], sta: string[], cli: string[])
});
pre.forEach(p => {
let glob: string
if (p === '/') {
if (p === 'index.html') {
glob = '/'
} else {
const ps = p.substring(1).split('/')
const ps = p.split('/')
glob = ps.length > 1 ? `${ps[0]}/*` : p
glob = `/${glob}`
}
Expand Down
4 changes: 2 additions & 2 deletions packages/sample-site-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch"
},
"devDependencies": {
"@sveltejs/kit": "^1.0.0-next.282",
"@sveltejs/kit": "1.0.0-next.292",
"@sveltekit-cdk/adapter": "workspace:*",
"@types/cookie": "^0.4.1",
"svelte": "^3.46.4",
"svelte-check": "^2.4.5",
"svelte-preprocess": "^4.10.3",
"svelte-preprocess": "^4.10.4",
"tslib": "^2.3.1",
"typescript": "~4.5.5"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch"
},
"devDependencies": {
"@sveltejs/kit": "v1.0.0-next.282",
"@sveltejs/kit": "1.0.0-next.292",
"@sveltekit-cdk/adapter": "workspace:*",
"msgpackr": "^1.5.4",
"svelte": "^3.46.4",
"svelte-check": "^2.4.5",
"svelte-preprocess": "^4.10.3",
"svelte-preprocess": "^4.10.4",
"tslib": "^2.3.1",
"typescript": "^4.5.5"
},
Expand Down
Loading

0 comments on commit 2cdd82b

Please sign in to comment.