File tree 3 files changed +39
-3
lines changed
3 files changed +39
-3
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ const unplugin = createUnplugin<Options>(
35
35
const importCSSModule = createCSSModule ( descriptor , id , preProcessCSSRes )
36
36
const variableName = getVariable ( descriptor )
37
37
code = injectCSSVars ( code , importCSSModule , variableName )
38
+ console . log ( code )
38
39
}
39
40
return code
40
41
} catch ( err : unknown ) {
Original file line number Diff line number Diff line change @@ -10,8 +10,13 @@ import type { Node } from 'estree-walker'
10
10
*/
11
11
export const getVariable = ( descriptor : SFCDescriptor ) => {
12
12
// ⭐⭐⭐ TODO: options
13
- // ⭐⭐⭐ TODO: setup composition
14
- const ast = babelParse ( descriptor . scriptSetup . content , {
13
+ let content = ''
14
+ if ( descriptor . script )
15
+ content = descriptor . script . content
16
+ else if ( descriptor . scriptSetup )
17
+ content = descriptor . scriptSetup . content
18
+
19
+ const ast = babelParse ( content , {
15
20
sourceType : 'module' ,
16
21
plugins : [ 'typescript' ] ,
17
22
} )
Original file line number Diff line number Diff line change 1
- <script setup lang="ts">
1
+ <! -- < script setup lang="ts">
2
2
import { reactive, ref } from 'vue'
3
3
/* import Comp from './comp.vue' */
4
4
const appAsd = () => 'red'
@@ -8,6 +8,36 @@ const appTheme3 = ref('red')
8
8
const appTheme4 = reactive({ color: 'red' })
9
9
const appTheme5 = { color: 'red' }
10
10
const appTheme6 = () => 'red'
11
+ </script> -->
12
+ <script>
13
+ import { defineComponent, reactive, ref } from 'vue'
14
+ /* import Comp from './comp.vue' */
15
+ const appAsd = () => 'red'
16
+ const color = appAsd()
17
+ const appTheme2 = 'red'
18
+ const appTheme3 = ref('red')
19
+ const appTheme4 = reactive({ color: 'red' })
20
+ const appTheme5 = { color: 'red' }
21
+ const appTheme6 = () => 'red'
22
+ export default defineComponent({
23
+ setup() {
24
+ const appAsd = () => 'red'
25
+ const color = appAsd()
26
+ const appTheme2 = 'red'
27
+ const appTheme3 = ref('red')
28
+ const appTheme4 = reactive({ color: 'red' })
29
+ const appTheme5 = { color: 'red' }
30
+ const appTheme6 = () => 'red'
31
+ return {
32
+ color,
33
+ appTheme2,
34
+ appTheme3,
35
+ appTheme4,
36
+ appTheme5,
37
+ appTheme6,
38
+ }
39
+ },
40
+ })
11
41
</script>
12
42
13
43
<template>
You can’t perform that action at this time.
0 commit comments