File tree Expand file tree Collapse file tree 2 files changed +21
-10
lines changed
Expand file tree Collapse file tree 2 files changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -2,17 +2,11 @@ import adapter, { type AdapterOptions } from "@sveltejs/adapter-cloudflare";
22import type { Adapter } from "@sveltejs/kit" ;
33import { getPlatformProxyOptions } from "../cloudflare-env-proxy.ts" ;
44
5- const isSvelteLanguageServer = ! ! process . argv . find ( ( arg ) =>
6- arg . includes ( "svelte-language-server" ) ,
7- ) ;
8-
95export default ( options ?: AdapterOptions ) : Adapter => {
10- if ( isSvelteLanguageServer ) {
11- // the svelte language server runs from the root and therefore may be running in a different cwd than the `Website.cwd`
12- // for now, we work around this by returning a noop adapter to avoid breaking svelte intellisense
6+ if ( shouldDisable ( ) ) {
137 return {
14- adapt ( ) { } ,
158 name : "alchemy-noop" ,
9+ adapt ( ) { } ,
1610 } ;
1711 }
1812 const { platformProxy : proxyOptions , ...config } = options ?? { } ;
@@ -23,3 +17,18 @@ export default (options?: AdapterOptions): Adapter => {
2317 ...config ,
2418 } ) ;
2519} ;
20+
21+ /**
22+ * Return true for `svelte-language-server`, `svelte-check`, and `svelte-kit sync`. This is because:
23+ * - The svelte language server runs from the root and therefore may be running in a different cwd than the `Website.cwd`, so disable to avoid breaking intellisense
24+ * - The `svelte-check` and `svelte-kit sync` commands do not require Cloudflare-specific configuration, so disable to avoid breaking the commands
25+ */
26+ function shouldDisable ( argv = process . argv ) : boolean {
27+ return (
28+ argv . some (
29+ ( arg ) =>
30+ arg . includes ( "svelte-check" ) || arg . includes ( "svelte-language-server" ) ,
31+ ) ||
32+ ( argv . some ( ( arg ) => arg . includes ( "svelte-kit" ) ) && argv . includes ( "sync" ) )
33+ ) ;
34+ }
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import path from "pathe";
22import { getPackageManagerRunner } from "../../util/detect-package-manager.ts" ;
33import type { Assets } from "../assets.ts" ;
44import type { Bindings } from "../bindings.ts" ;
5+ import { withSkipPathValidation } from "../miniflare/paths.ts" ;
56import {
67 spreadBuildProps ,
78 spreadDevProps ,
@@ -34,8 +35,9 @@ export async function Vite<B extends Bindings>(
3435 port = args [ index + 1 ] ;
3536 } else {
3637 try {
37- const config = await import (
38- path . resolve ( props . cwd ?? process . cwd ( ) , "vite.config.ts" )
38+ const config = await withSkipPathValidation (
39+ ( ) =>
40+ import ( path . resolve ( props . cwd ?? process . cwd ( ) , "vite.config.ts" ) ) ,
3941 ) ;
4042 port = config . default ?. server ?. port ?? 5173 ;
4143 } catch { }
You can’t perform that action at this time.
0 commit comments