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: pass validated svelte config to adapters #1559

Merged
11 changes: 11 additions & 0 deletions .changeset/smooth-items-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@sveltejs/adapter-begin': patch
'@sveltejs/adapter-cloudflare-workers': patch
'@sveltejs/adapter-netlify': patch
'@sveltejs/adapter-node': patch
'@sveltejs/adapter-static': patch
'@sveltejs/adapter-vercel': patch
'@sveltejs/kit': patch
---

Pass validated svelte config to adapter adapt function
2 changes: 1 addition & 1 deletion packages/adapter-begin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function () {
const adapter = {
name: '@sveltejs/adapter-begin',

async adapt(utils) {
async adapt({ utils }) {
utils.log.minor('Parsing app.arc file');
const { static: static_mount_point } = parse_arc('app.arc');

Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-cloudflare-workers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function () {
/** @type {import('@sveltejs/kit').Adapter} */
const adapter = {
name: '@sveltejs/adapter-cloudflare-workers',
async adapt(utils) {
async adapt({ utils }) {
const { site } = validate_config(utils);

const bucket = site.bucket;
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-netlify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function () {
const adapter = {
name: '@sveltejs/adapter-netlify',

async adapt(utils) {
async adapt({ utils }) {
const { publish, functions } = validate_config().build;

utils.rimraf(publish);
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function ({ out = 'build' } = {}) {
const adapter = {
name: '@sveltejs/adapter-node',

async adapt(utils) {
async adapt({ utils }) {
utils.log.minor('Copying assets');
const static_directory = join(out, 'assets');
utils.copy_client_files(static_directory);
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-static/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function ({ pages = 'build', assets = pages, fallback = null } =
const adapter = {
name: '@sveltejs/adapter-static',

async adapt(utils) {
async adapt({ utils }) {
utils.copy_static_files(assets);
utils.copy_client_files(assets);

Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-vercel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function () {
const adapter = {
name: '@sveltejs/adapter-vercel',

async adapt(utils) {
async adapt({ utils }) {
const dir = '.vercel_build_output';
utils.rimraf(dir);

Expand Down
3 changes: 2 additions & 1 deletion packages/kit/src/core/adapt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import { get_utils } from './utils.js';
* @param {import('types/internal').BuildData} build_data
* @param {{ cwd?: string, verbose: boolean }} opts
*/

jthegedus marked this conversation as resolved.
Show resolved Hide resolved
export async function adapt(config, build_data, { cwd = process.cwd(), verbose }) {
const { name, adapt } = config.kit.adapter;

console.log(colors.bold().cyan(`\n> Using ${name}`));

const log = logger({ verbose });
const utils = get_utils({ cwd, config, build_data, log });
await adapt(utils);
await adapt({ utils, svelteConfig: config });
jthegedus marked this conversation as resolved.
Show resolved Hide resolved

log.success('done');
}
8 changes: 7 additions & 1 deletion packages/kit/types/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ export type AdapterUtils = {

export type Adapter = {
name: string;
adapt: (utils: AdapterUtils) => Promise<void>;
adapt: ({
utils,
svelteConfig
}: {
utils: AdapterUtils;
svelteConfig: ValidatedConfig;
jthegedus marked this conversation as resolved.
Show resolved Hide resolved
}) => Promise<void>;
};

export type Config = {
Expand Down
Loading