File tree Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change 1
1
import { Controller } from '@hotwired/stimulus' ;
2
- import { VERSION } from 'svelte/compiler' ;
3
2
4
3
class default_1 extends Controller {
5
4
async connect ( ) {
@@ -39,8 +38,8 @@ class default_1 extends Controller {
39
38
this . dispatch ( name , { detail, prefix : 'svelte' } ) ;
40
39
}
41
40
async mountSvelteComponent ( Component , options ) {
42
- if ( VERSION ?. startsWith ( '5' ) ) {
43
- const { mount } = await import ( 'svelte' ) ;
41
+ const { mount } = await import ( 'svelte' ) ;
42
+ if ( mount ) {
44
43
return mount ( Component , options ) ;
45
44
}
46
45
return new Component ( options ) ;
Original file line number Diff line number Diff line change 1
1
import { Controller } from '@hotwired/stimulus' ;
2
2
import type { SvelteComponent , ComponentConstructorOptions , ComponentType } from 'svelte' ;
3
- import { VERSION as SVELTE_VERSION } from 'svelte/compiler' ;
4
3
5
4
export default class extends Controller < Element & { root ?: SvelteComponent } > {
6
5
private app : SvelteComponent ;
@@ -70,9 +69,10 @@ export default class extends Controller<Element & { root?: SvelteComponent }> {
70
69
Component : ComponentType ,
71
70
options : ComponentConstructorOptions
72
71
) : Promise < SvelteComponent > {
73
- if ( SVELTE_VERSION ?. startsWith ( '5' ) ) {
74
- // @ts -ignore
75
- const { mount } = await import ( 'svelte' ) ;
72
+ // @ts -ignore
73
+ const { mount } = await import ( 'svelte' ) ;
74
+ if ( mount ) {
75
+ // `mount` is only available in Svelte >= 5
76
76
return mount ( Component , options ) ;
77
77
}
78
78
You can’t perform that action at this time.
0 commit comments