Skip to content
Open
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
10 changes: 7 additions & 3 deletions packages/language-server/src/lib/documents/configLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ const _dynamicImport = new Function('modulePath', 'return import(modulePath)') a
modulePath: URL
) => Promise<any>;

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.
Expand Down Expand Up @@ -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;
}
Expand Down
10 changes: 8 additions & 2 deletions packages/svelte-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +38 to +40
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was also unflagged in 22.18: https://github.com/nodejs/node/blob/00a42d82053e2f59ef4130cd0fe9a85b623a64be/doc/changelogs/CHANGELOG_V22.md#22.18.0.

Suggested change
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
const add_experimental_strip_types_flag =
(node_major === 22 && node_minor > 5 && node_minor < 18) || // added behind flag in 22.6, unflagged in 22.18
(node_major === 23 && node_minor < 6); // unflagged in 23.6

namespace TagCloseRequest {
export const type: RequestType<TextDocumentPositionParams, string, any> = new RequestType(
'html/tag'
Expand Down Expand Up @@ -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<string[]>('runtime-args');
if (runtimeArgs !== undefined) {
runExecArgv.push(...runtimeArgs);
Expand Down