Skip to content
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

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

Closed
syropian opened this issue Sep 24, 2021 · 3 comments

Comments

@syropian
Copy link

syropian commented Sep 24, 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

@edison1105
Copy link
Member

I would say this should be

const stringWithOpenAndClosedScriptTag = "<script><\/script>"

@syropian
Copy link
Author

syropian commented Sep 24, 2021

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

@syropian syropian changed the title script-setup: String with "export default { ... }" or "<script>...</script>" causes compilation error script-setup: String with "export default { ... }" causes compilation error Sep 24, 2021
@syropian syropian changed the title script-setup: String with "export default { ... }" causes compilation error script-setup: String with "export default { ... }" causes compilation error if lang is "ts" Sep 24, 2021
@yyx990803
Copy link
Member

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

vue-loader does not suffer from this issue AFAIK.

aleclarson pushed a commit to aleclarson/vite that referenced this issue Nov 8, 2021
patak-dev pushed a commit to vitejs/vite-plugin-vue that referenced this issue Dec 2, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants