Skip to content
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: 5 additions & 0 deletions .changeset/nice-mammals-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': major
---

breaking: `config` exported from a universal route file takes precedence over a server one
2 changes: 1 addition & 1 deletion packages/kit/src/exports/public.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export interface Adapter {
* Test support for `read` from `$app/server`.
* @param details.config The merged adapter-specific route config exported from the route with `export const config`
*/
read?: (details: { config: any; route: { id: string } }) => boolean;
read?: (details: { config: Record<string, any>; route: { id: string } }) => boolean;

/**
* Test support for `instrumentation.server.js`. To pass, the adapter must support running `instrumentation.server.js` prior to the application code.
Expand Down
10 changes: 5 additions & 5 deletions packages/kit/src/types/internal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ export interface ServerErrorNode {
}

export interface ServerMetadataRoute {
config: any;
config: Record<string, any>;
api: {
methods: Array<HttpMethod | '*'>;
};
Expand Down Expand Up @@ -426,7 +426,7 @@ export interface UniversalNode {
ssr?: boolean;
csr?: boolean;
trailingSlash?: TrailingSlash;
config?: any;
config?: Record<string, any>;
entries?: PrerenderEntryGenerator;
}

Expand All @@ -437,7 +437,7 @@ export interface ServerNode {
csr?: boolean;
trailingSlash?: TrailingSlash;
actions?: Actions;
config?: any;
config?: Record<string, any>;
entries?: PrerenderEntryGenerator;
}

Expand Down Expand Up @@ -511,7 +511,7 @@ export type RemotePrerenderInputsGenerator<Input = any> = () => MaybePromise<Inp
export type SSREndpoint = Partial<Record<HttpMethod, RequestHandler>> & {
prerender?: PrerenderOption;
trailingSlash?: TrailingSlash;
config?: any;
config?: Record<string, any>;
entries?: PrerenderEntryGenerator;
fallback?: RequestHandler;
};
Expand Down Expand Up @@ -560,7 +560,7 @@ export interface SSRState {
*/
before_handle?: (
event: RequestEvent,
config: any,
config: Record<string, any>,
prerender: PrerenderOption,
handle: () => Promise<Response>
) => Promise<Response>;
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/utils/features.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @param {string} route_id
* @param {any} config
* @param {Record<string, any>} config
* @param {string} feature
* @param {import('@sveltejs/kit').Adapter | undefined} adapter
*/
Expand Down
8 changes: 3 additions & 5 deletions packages/kit/src/utils/page_nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,19 @@ export class PageNodes {
}

get_config() {
/** @type {any} */
/** @type {Record<string, any>} */
let current = {};

for (const node of this.data) {
if (!node?.universal?.config && !node?.server?.config) continue;

current = {
...current,
// TODO: should we override the server config value with the universal value similar to other page options?
...node?.universal?.config,
...node?.server?.config
...node?.server?.config,
...node?.universal?.config
};
}

// TODO 3.0 always return `current`? then we can get rid of `?? {}` in other places

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not much point in doing this since we test if this is undefined before falling back to the +server.js exported config

if (page?.config && endpoint?.config) {

return Object.keys(current).length ? current : undefined;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/kit/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ declare module '@sveltejs/kit' {
* Test support for `read` from `$app/server`.
* @param details.config The merged adapter-specific route config exported from the route with `export const config`
*/
read?: (details: { config: any; route: { id: string } }) => boolean;
read?: (details: { config: Record<string, any>; route: { id: string } }) => boolean;

/**
* Test support for `instrumentation.server.js`. To pass, the adapter must support running `instrumentation.server.js` prior to the application code.
Expand Down
Loading