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

feat: Move hooks.{js|ts} init to Server.init instead of Server.respond #6179

Merged
merged 22 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
fa53fbb
feat: Move hooks.js initialization into Server.init
elliott-with-the-longest-name-on-github Aug 23, 2022
02c5764
fix: Server type
elliott-with-the-longest-name-on-github Aug 23, 2022
3bfd40c
feat: Await Server.init in adapters
elliott-with-the-longest-name-on-github Aug 23, 2022
286648a
feat: Await server.init in preview
elliott-with-the-longest-name-on-github Aug 23, 2022
204acb1
fix: Init server during prerender
elliott-with-the-longest-name-on-github Aug 23, 2022
16cdc7b
feat: Init hooks when dev mode starts instead of on first request
elliott-with-the-longest-name-on-github Aug 23, 2022
f8bd413
fix: Prerendering, but better
elliott-with-the-longest-name-on-github Aug 23, 2022
ea9c218
feat: Test env vars in prerender
elliott-with-the-longest-name-on-github Aug 23, 2022
c6a7f6d
fix: Remove console.log
elliott-with-the-longest-name-on-github Aug 23, 2022
7f31360
fix: Import in hooks.js of basics test app
elliott-with-the-longest-name-on-github Aug 23, 2022
3fba16e
changeset
elliott-with-the-longest-name-on-github Aug 23, 2022
2c7e2a8
Update packages/adapter-netlify/src/serverless.js
elliott-with-the-longest-name-on-github Aug 23, 2022
9583fbc
Update packages/kit/src/vite/build/build_server.js
elliott-with-the-longest-name-on-github Aug 23, 2022
6cb779c
feat: Enable top-level await in `adapter-node`
elliott-with-the-longest-name-on-github Aug 23, 2022
8ef2f83
feat: Add warning comment for future devs
elliott-with-the-longest-name-on-github Aug 23, 2022
7afab3e
fix: Init env prior to hooks
elliott-with-the-longest-name-on-github Aug 23, 2022
6131dd3
Merge branch '6147/sejohnson-move-hooks-init' of github.com:sveltejs/…
elliott-with-the-longest-name-on-github Aug 23, 2022
a8c62b2
fix: Remove dear Rich
elliott-with-the-longest-name-on-github Aug 23, 2022
23a9206
Merge branch 'master' into 6147/sejohnson-move-hooks-init
elliott-with-the-longest-name-on-github Aug 23, 2022
580ffd2
fix: Apparently didn't like my tsconfig
elliott-with-the-longest-name-on-github Aug 23, 2022
e9286ad
fix: Move env and hooks initialization later
elliott-with-the-longest-name-on-github Aug 23, 2022
5b9b0db
move user_hooks init back from whence it came
Rich-Harris Aug 24, 2022
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
Prev Previous commit
Next Next commit
feat: Enable top-level await in adapter-node
  • Loading branch information
commit 6cb779ca202814d62acfb7edbfe115c1fb437191
11 changes: 1 addition & 10 deletions packages/adapter-node/src/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { env } from './env.js';
const server = new Server(manifest);
// Dear Rich,
// it says top-level await isn't available. Should it be?
let init_promise = server.init({ env: process.env });
await server.init({ env: process.env });
const origin = env('ORIGIN', undefined);
const xff_depth = parseInt(env('XFF_DEPTH', '1'));

Expand All @@ -23,14 +23,6 @@ const host_header = env('HOST_HEADER', 'host').toLowerCase();

const __dirname = path.dirname(fileURLToPath(import.meta.url));

/** @type {import('polka').Middleware} */
const init = async () => {
if (init_promise !== null) {
await init_promise;
init_promise = null;
}
};

/**
* @param {string} path
* @param {boolean} client
Expand Down Expand Up @@ -142,7 +134,6 @@ function get_origin(headers) {

export const handler = sequence(
[
init,
serve(path.join(__dirname, '/client'), true),
serve(path.join(__dirname, '/static')),
serve(path.join(__dirname, '/prerendered')),
Expand Down
3 changes: 2 additions & 1 deletion packages/adapter-node/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"noImplicitAny": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"module": "es2020",
"module": "es2022",
"target": "es2017",
"baseUrl": ".",
"paths": {
"@sveltejs/kit": ["../kit/types/index"]
Expand Down