Subscribe on changes!

script-setup: String with "export default { ... }" causes compilation error if lang is "ts"

avatar
Sep 24th 2021

Version

3.2.16

Reproduction link

sfc.vuejs.org/

Steps to reproduce

  • See the exportOnNewLineString
  • See the exportOnOneLineString variable for an example of when using export default does not break

What is expected?

I expect these strings to not cause a compilation error. It would be fairly common to have strings like these on a documentation page.

What is actually happening?

The compiler fails with the error:

SyntaxError: Unexpected token, expected "," (22:12)

Note: It only fails when using lang="ts" with setup

avatar
Sep 24th 2021

I would say this should be

const stringWithOpenAndClosedScriptTag = "<script><\/script>"
avatar
Sep 24th 2021

@edison1105 Oop, you're right, I'll edit the issue to just mention the export bug!

avatar
Sep 24th 2021

If you are using Vite, this is fixed in @vitejs/plugin-vue 1.9.2.

vue-loader does not suffer from this issue AFAIK.