File tree Expand file tree Collapse file tree 1 file changed +23
-16
lines changed
packages/runtime-core/src/helpers Expand file tree Collapse file tree 1 file changed +23
-16
lines changed Original file line number Diff line number Diff line change @@ -2,22 +2,29 @@ import { getCurrentInstance } from '../component'
2
2
import { EMPTY_OBJ } from '@vue/shared'
3
3
import { warn } from '../warning'
4
4
5
- export function useCSSModule ( name = '$style' ) : Record < string , string > {
6
- const instance = getCurrentInstance ( ) !
7
- if ( ! instance ) {
8
- __DEV__ && warn ( `useCSSModule must be called inside setup()` )
5
+ export const useCSSModule = ( name = '$style' ) : Record < string , string > => {
6
+ if ( ! __GLOBAL__ ) {
7
+ const instance = getCurrentInstance ( ) !
8
+ if ( ! instance ) {
9
+ __DEV__ && warn ( `useCSSModule must be called inside setup()` )
10
+ return EMPTY_OBJ
11
+ }
12
+ const modules = instance . type . __cssModules
13
+ if ( ! modules ) {
14
+ __DEV__ && warn ( `Current instance does not have CSS modules injected.` )
15
+ return EMPTY_OBJ
16
+ }
17
+ const mod = modules [ name ]
18
+ if ( ! mod ) {
19
+ __DEV__ &&
20
+ warn ( `Current instance does not have CSS module named "${ name } ".` )
21
+ return EMPTY_OBJ
22
+ }
23
+ return mod as Record < string , string >
24
+ } else {
25
+ if ( __DEV__ ) {
26
+ warn ( `useCSSModule() is not supported in the global build.` )
27
+ }
9
28
return EMPTY_OBJ
10
29
}
11
- const modules = instance . type . __cssModules
12
- if ( ! modules ) {
13
- __DEV__ && warn ( `Current instance does not have CSS modules injected.` )
14
- return EMPTY_OBJ
15
- }
16
- const mod = modules [ name ]
17
- if ( ! mod ) {
18
- __DEV__ &&
19
- warn ( `Current instance does not have CSS module named "${ name } ".` )
20
- return EMPTY_OBJ
21
- }
22
- return mod as Record < string , string >
23
30
}
You can’t perform that action at this time.
0 commit comments