Skip to content

Commit

Permalink
restore app-level hydrate option
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Jan 18, 2022
1 parent bbfc17d commit 28acd1f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 13 deletions.
1 change: 1 addition & 0 deletions documentation/docs/14-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const config = {
protocol: null
},
host: null,
hydrate: true,
inlineStyleThreshold: 0,
methodOverride: {
parameter: '_method',
Expand Down
1 change: 1 addition & 0 deletions packages/kit/src/core/build/build_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export class App {
error.stack = this.options.get_stack(error);
},
hooks,
hydrate: ${s(config.kit.hydrate)},
manifest,
method_override: ${s(config.kit.methodOverride)},
paths: { base, assets },
Expand Down
4 changes: 2 additions & 2 deletions packages/kit/src/core/config/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test('fills in defaults', () => {
protocol: null
},
host: null,
hydrate: null,
hydrate: true,
inlineStyleThreshold: 0,
methodOverride: {
parameter: '_method',
Expand Down Expand Up @@ -146,7 +146,7 @@ test('fills in partial blanks', () => {
protocol: null
},
host: null,
hydrate: null,
hydrate: true,
inlineStyleThreshold: 0,
methodOverride: {
parameter: '_method',
Expand Down
9 changes: 1 addition & 8 deletions packages/kit/src/core/config/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,7 @@ const options = object(

host: string(null),

// TODO remove this for 1.0
hydrate: validate(null, (input) => {
if (input !== undefined) {
throw new Error(
'config.kit.hydrate has been removed — use the handle hook instead: https://kit.svelte.dev/docs#hooks-handle'
);
}
}),
hydrate: boolean(true),

inlineStyleThreshold: number(0),

Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/core/config/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test('load default config (esm)', async () => {
protocol: null
},
host: null,
hydrate: null,
hydrate: true,
inlineStyleThreshold: 0,
methodOverride: {
parameter: '_method',
Expand Down
6 changes: 4 additions & 2 deletions packages/kit/src/runtime/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export async function respond(incoming, options, state = {}) {
print_error('query', 'searchParams');

const resolve_opts = {
hydrate: true,
hydrate: options.hydrate,
router: true,
ssr: true
};
Expand All @@ -92,7 +92,9 @@ export async function respond(incoming, options, state = {}) {
return await options.hooks.handle({
request,
resolve: async (request, opts) => {
if (opts && 'hydrate' in opts) resolve_opts.hydrate = /** @type {boolean} */ (opts.hydrate);
if (resolve_opts.hydrate && opts && 'hydrate' in opts) {
resolve_opts.hydrate = /** @type {boolean} */ (opts.hydrate);
}
if (opts && 'router' in opts) resolve_opts.router = /** @type {boolean} */ (opts.router);
if (opts && 'ssr' in opts) resolve_opts.ssr = /** @type {boolean} */ (opts.ssr);

Expand Down

0 comments on commit 28acd1f

Please sign in to comment.