Skip to content

Commit

Permalink
introduce devPlatform kit configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
dario-piotrowicz committed Jan 20, 2024
1 parent 043ad0f commit 4a847e4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/kit/src/core/config/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,9 @@ const options = object(
version: object({
name: string(Date.now().toString()),
pollInterval: number(0)
})
}),

devPlatform: object({}, true),
})
},
true
Expand Down
6 changes: 6 additions & 0 deletions packages/kit/src/exports/public.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,12 @@ export interface KitConfig {
*/
pollInterval?: number;
};
/**
* Platform object to be used during development, allowing the simulation of a production platform during local development.
*
* @default undefined
*/
devPlatform?: unknown;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/kit/src/exports/vite/dev/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,8 @@ export async function dev(vite, vite_config, svelte_config) {
read: (file) => fs.readFileSync(path.join(svelte_config.kit.files.assets, file)),
before_handle: (event, config, prerender) => {
async_local_storage.enterWith({ event, config, prerender });
}
},
platform: svelte_config.kit.devPlatform,
});

if (rendered.status === 404) {
Expand Down
3 changes: 2 additions & 1 deletion packages/kit/src/exports/vite/preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ export async function preview(vite, vite_config, svelte_config) {
if (remoteAddress) return remoteAddress;
throw new Error('Could not determine clientAddress');
},
read: (file) => fs.readFileSync(join(svelte_config.kit.files.assets, file))
read: (file) => fs.readFileSync(join(svelte_config.kit.files.assets, file)),
platform: svelte_config.kit.devPlatform,
})
);
});
Expand Down
6 changes: 6 additions & 0 deletions packages/kit/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,12 @@ declare module '@sveltejs/kit' {
*/
pollInterval?: number;
};
/**
* Platform object to be used during development, allowing the simulation of a production platform during local development.
*
* @default undefined
*/
devPlatform?: unknown;
}

/**
Expand Down

0 comments on commit 4a847e4

Please sign in to comment.