File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
packages/language-server/src Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,19 @@ export function importSvelte(fromPath: string): typeof svelte {
5858 const pkg = getPackageInfo ( 'svelte' , fromPath ) ;
5959 const main = resolve ( pkg . path , 'compiler' ) ;
6060 Logger . debug ( 'Using Svelte v' + pkg . version . full , 'from' , main ) ;
61- return dynamicRequire ( main + ( pkg . version . major >= 4 ? '.cjs' : '' ) ) ;
61+ if ( pkg . version . major === 4 ) {
62+ return dynamicRequire ( main + '.cjs' ) ;
63+ } else if ( pkg . version . major === 5 ) {
64+ // TODO remove once Svelte 5 is released
65+ // (we switched from compiler.cjs to compiler/index.js at some point)
66+ try {
67+ return dynamicRequire ( main ) ;
68+ } catch ( e ) {
69+ return dynamicRequire ( main + '.cjs' ) ;
70+ }
71+ } else {
72+ return dynamicRequire ( main ) ;
73+ }
6274}
6375
6476export function importSveltePreprocess ( fromPath : string ) : typeof sveltePreprocess {
You can’t perform that action at this time.
0 commit comments