Skip to content

Commit

Permalink
fix: fix script parse error
Browse files Browse the repository at this point in the history
  • Loading branch information
baiwusanyu-c committed May 4, 2023
1 parent 3a957d2 commit fb51878
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
8 changes: 7 additions & 1 deletion packages/core/runtime/handle-variable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ export function handleVBindVariable(
ctx: IVueCSSVarsCtx,
) {
const { descriptor } = parse(code)
const lang = descriptor?.script?.lang ?? 'js'
let lang = 'js'
if (descriptor?.scriptSetup?.lang)
lang = descriptor.scriptSetup.lang

if (descriptor?.script?.lang)
lang = descriptor.script.lang

// ⭐TODO: 只支持 .vue ? jsx, tsx, js, ts ?
if (!JSX_TSX_REG.test(`.${lang}`)) {
ctx.isScriptSetup = !!descriptor.scriptSetup
Expand Down
2 changes: 1 addition & 1 deletion play/vite/src/assets/css/foo.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#foo{
color: v-bind-m(sassColor);
background: #ffebf8;
background: v-bind-m(sc2);
width: 200px;
height: 30px;
}
Expand Down
8 changes: 4 additions & 4 deletions play/vite/src/views/app/App.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script setup lang="ts">
<script setup lang="tsx">
import { reactive, ref } from 'vue'
import Comp from '../../comp.vue'
import Comp2 from '../../comp2.vue'
Expand All @@ -14,10 +14,10 @@ const appTheme4 = reactive({ color: 'red' })
const appTheme5 = { color: 'red' }
const appTheme6 = () => 'red'
</script>
<!--
<script lang="ts">

<script lang="tsx">
const sc2 = 'red'
</script> -->
</script>
<!-- <script lang="ts">
import { defineComponent, reactive, ref } from 'vue'
/* import Comp from './comp.vue' */
Expand Down

0 comments on commit fb51878

Please sign in to comment.