Skip to content

Invalid syntax in Vue templates after build #598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dulnan opened this issue Apr 16, 2025 · 2 comments · Fixed by nuxt-contrib/vue-sfc-transformer#28
Closed

Invalid syntax in Vue templates after build #598

dulnan opened this issue Apr 16, 2025 · 2 comments · Fixed by nuxt-contrib/vue-sfc-transformer#28
Labels
bug Something isn't working upstream

Comments

@dulnan
Copy link

dulnan commented Apr 16, 2025

I am using version 1.0.1 of @nuxt/module-builder.

Given this Vue component located in ./src/runtime/components/Foobar.vue:

<template>
  <div>
    <div>{{ $test('foobar', "Foobar 'test'") }}</div>
    <div>{{ $test('foobar', 'Foobar test') }}</div>
    <div>{{ $test('foobar', `Foobar ' " ''" test`) }}</div>
  </div>
</template>

<script lang="ts" setup>
const $test = (key: string, text: string): string => key
</script>

After running nuxt-module-build build, the output in ./dist/runtime/components/Foobar.vue looks like this:

<template>
  <div>
    <div>{{ $test(\"foobar\", \"Foobar "test"\") }}</div>
    <div>{{ $test('foobar', 'Foobar test') }}</div>
    <div>{{ $test(\"foobar\", `Foobar " \" ""\" test`) }}</div>
  </div>
</template>

<script setup>
const $test = (key, text) => key;
</script>

Here the first and the third call to $test produced invalid syntax. It looks like it tries to escape the quotes when it wouldn't be needed, especially in the third example using backticks.

@danielroe
Copy link
Member

you can refresh your lockfile to pull in [email protected]

@dulnan
Copy link
Author

dulnan commented Apr 17, 2025

Thank you, the fix works!

I'd also like to say a big thanks for the new module builder version, especially with vue-sfc-transformer. It has had an insanse positive impact on performance. One of my modules contains around 200 components which previously were all fully type-checked in every project and they were subject to custom compilerOptions per project. But now that these components are shipped already transpiled, the typecheck is significantly faster. Like 3-5 times faster!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants