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

Remove comment about adapter-auto once a specific sveltekit adapter is chosen #436

Merged
merged 2 commits into from
Feb 7, 2025
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/happy-news-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'sv': patch
---

Remove comment about adapter-auto once a specific sveltekit adapter is chosen
6 changes: 4 additions & 2 deletions packages/addons/_tests/sveltekit-adapter/test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { expect } from '@playwright/test';
import { setupTest } from '../_setup/suite.ts';
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
import sveltekitAdapter from '../../sveltekit-adapter/index.ts';
import { setupTest } from '../_setup/suite.ts';

const addonId = sveltekitAdapter.id;
const { test, variants, prepareServer } = setupTest({ [addonId]: sveltekitAdapter });
Expand All @@ -13,5 +15,5 @@ test.concurrent.for(kitOnly)('core - %s', async (variant, { page, ...ctx }) => {
// kill server process when we're done
ctx.onTestFinished(async () => await close());

expect(true).toBe(true);
expect(await readFile(join(cwd, 'svelte.config.js'), 'utf8')).not.toMatch('adapter-auto');
});
8 changes: 8 additions & 0 deletions packages/addons/sveltekit-adapter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ export default defineAddon({
) as AstTypes.ObjectProperty | undefined;

if (kitConfig && kitConfig.value.type === 'ObjectExpression') {
const adapterProp = kitConfig.value.properties.find(
(p) =>
p.type === 'ObjectProperty' && p.key.type === 'Identifier' && p.key.name === 'adapter'
);
if (adapterProp) {
adapterProp.comments = [];
}

// only overrides the `adapter` property so we can reset it's args
object.overrideProperties(kitConfig.value, {
adapter: functions.callByIdentifier(adapterName, [])
Expand Down