diff --git a/packages/language-server/src/lib/documents/configLoader.ts b/packages/language-server/src/lib/documents/configLoader.ts index 49413a6f8..e65098466 100644 --- a/packages/language-server/src/lib/documents/configLoader.ts +++ b/packages/language-server/src/lib/documents/configLoader.ts @@ -47,10 +47,10 @@ const _dynamicImport = new Function('modulePath', 'return import(modulePath)') a modulePath: URL ) => Promise; -const configRegex = /\/svelte\.config\.(js|cjs|mjs)$/; +const configRegex = /\/svelte\.config\.(js|ts|cjs|mjs|mts)$/; /** - * Loads svelte.config.{js,cjs,mjs} files. Provides both a synchronous and asynchronous + * Loads svelte.config.{js,ts,cjs,mjs,mts} files. Provides both a synchronous and asynchronous * interface to get a config file because snapshots need access to it synchronously. * This means that another instance (the ts service host on startup) should make * sure that all config files are loaded before snapshots are retrieved. @@ -143,7 +143,11 @@ export class ConfigLoader { return this.fs.existsSync(path) ? path : undefined; }; const configPath = - tryFindConfigPath('js') || tryFindConfigPath('cjs') || tryFindConfigPath('mjs'); + tryFindConfigPath('js') || + tryFindConfigPath('ts') || + tryFindConfigPath('cjs') || + tryFindConfigPath('mjs') || + tryFindConfigPath('mts'); if (configPath) { return configPath; } diff --git a/packages/svelte-vscode/src/extension.ts b/packages/svelte-vscode/src/extension.ts index dae135bf8..8653a4e66 100644 --- a/packages/svelte-vscode/src/extension.ts +++ b/packages/svelte-vscode/src/extension.ts @@ -33,7 +33,11 @@ import { addFindComponentReferencesListener } from './typescript/findComponentRe import { addFindFileReferencesListener } from './typescript/findFileReferences'; import { setupSvelteKit } from './sveltekit'; import { resolveCodeLensMiddleware } from './middlewares'; - +import { versions } from 'node:process'; +const [node_major, node_minor] = (versions?.node ?? '0.0.0-unknown').split('.', 3).map(Number); +const add_experimental_strip_types_flag = + (node_major === 22 && node_minor > 5) || // added behind flag in 22.6.0 + (node_major === 23 && node_minor < 6); // unflagged in 23.6 namespace TagCloseRequest { export const type: RequestType = new RequestType( 'html/tag' @@ -123,7 +127,9 @@ export function activateSvelteLanguageServer(context: ExtensionContext) { // Add --experimental-modules flag for people using node 12 < version < 12.17 // Remove this in mid 2022 and bump vs code minimum required version to 1.55 const runExecArgv: string[] = ['--experimental-modules']; - + if (add_experimental_strip_types_flag) { + runExecArgv.push('--experimental-strip-types'); + } const runtimeArgs = runtimeConfig.get('runtime-args'); if (runtimeArgs !== undefined) { runExecArgv.push(...runtimeArgs);