File tree Expand file tree Collapse file tree 4 files changed +208
-244
lines changed
src/routes/demo/cookbook/glob-import Expand file tree Collapse file tree 4 files changed +208
-244
lines changed Original file line number Diff line number Diff line change 110
110
"cross-spawn" : " 7.0.3" ,
111
111
"csstype" : " 3.1.3" ,
112
112
"dotenv" : " 16.4.5" ,
113
- "esbuild" : " 0.24.0 " ,
113
+ "esbuild" : " 0.25.4 " ,
114
114
"eslint" : " 9.25.1" ,
115
115
"eslint-plugin-import" : " 2.29.1" ,
116
116
"eslint-plugin-no-only-tests" : " 3.3.0" ,
Original file line number Diff line number Diff line change 8
8
"@algolia/autocomplete-core" : " 1.7.4" ,
9
9
"@algolia/client-search" : " 4.14.3" ,
10
10
"@builder.io/partytown" : " 0.10.2" ,
11
- "@builder.io/qwik" : " ../qwik" ,
12
- "@builder.io/qwik-city" : " ../qwik-router" ,
13
- "@builder.io/sdk-qwik" : " 0.14.31" ,
14
11
"@emotion/react" : " 11.13.0" ,
15
12
"@emotion/styled" : " 11.13.0" ,
16
13
"@modular-forms/qwik" : " 0.23.1" ,
Original file line number Diff line number Diff line change 1
- import {
2
- type Component ,
3
- component$ ,
4
- useSignal ,
5
- useTask$ ,
6
- isDev ,
7
- } from '@qwik.dev/core' ;
1
+ import { component$ , type Component } from '@qwik.dev/core' ;
8
2
9
- const metaGlobComponents : Record < string , any > = import . meta. glob (
3
+ const metaGlobComponents = import . meta. glob < Component > (
10
4
'/src/routes/demo/cookbook/glob-import/examples/*' ,
11
- {
12
- import : 'default' ,
13
- eager : ! isDev ,
14
- }
5
+ { import : 'default' }
15
6
) ;
16
7
17
8
export default component$ ( ( ) => {
@@ -24,15 +15,14 @@ export default component$(() => {
24
15
) ;
25
16
} ) ;
26
17
18
+ const loaded : Record < string , Component > = { } ;
27
19
export const MetaGlobExample = component$ < { name : string } > ( ( { name } ) => {
28
- const MetaGlobComponent = useSignal < Component < any > > ( ) ;
29
- const componentPath = `/src/routes/demo/cookbook/glob-import/examples/${ name } .tsx` ;
30
-
31
- useTask$ ( async ( ) => {
32
- MetaGlobComponent . value = isDev
33
- ? await metaGlobComponents [ componentPath ] ( ) // We need to call `await metaGlobComponents[componentPath]()` in development as it is `eager:false`
34
- : metaGlobComponents [ componentPath ] ; // We need to directly access the `metaGlobComponents[componentPath]` expression in preview/production as it is `eager:true`
35
- } ) ;
20
+ const Cmp = loaded [ name ] ;
21
+ if ( ! Cmp ) {
22
+ const componentPath = `/src/routes/demo/cookbook/glob-import/examples/${ name } .tsx` ;
23
+ const promise = metaGlobComponents [ componentPath ] ( ) ;
24
+ throw promise . then ( ( c ) => ( loaded [ name ] = c ) ) ;
25
+ }
36
26
37
- return < > { MetaGlobComponent . value && < MetaGlobComponent . value /> } < /> ;
27
+ return < Cmp /> ;
38
28
} ) ;
You can’t perform that action at this time.
0 commit comments