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

Using vue-property-decorator and "default" string causes error #27

Closed
rs3d opened this issue Jul 20, 2022 · 4 comments
Closed

Using vue-property-decorator and "default" string causes error #27

rs3d opened this issue Jul 20, 2022 · 4 comments

Comments

@rs3d
Copy link

rs3d commented Jul 20, 2022

Hi,

I'm experiencing a strange issue.
Whenever I use default as class prop or even as a string like defaultSomething in a JS-comment in my .vue-files, the following error shows up:

Error:

10:57:46 AM [vite] Internal server error: Cannot overwrite across a split point
  Plugin: vite:vue2
  File: app/src/components/Form/FormStepProgress.vue
      at MagicString.overwrite (\app\node_modules\@vue\compiler-sfc\dist\compiler-sfc.js:2362:11)
      at \app\node_modules\@vue\compiler-sfc\dist\compiler-sfc.js:8182:15
      at Array.forEach (<anonymous>)
      at Object.rewriteDefault (\app\node_modules\@vue\compiler-sfc\dist\compiler-sfc.js:8180:9)
      at genScriptCode (\app\node_modules\@vitejs\plugin-vue2\dist\index.cjs:2993:37)
      at transformMain (\app\node_modules\@vitejs\plugin-vue2\dist\index.cjs:2911:54)
      at TransformContext.transform (\app\node_modules\@vitejs\plugin-vue2\dist\index.cjs:3248:16)
      at Object.transform (file:///app/node_modules/vite/dist/node/chunks/dep-1513d487.js:35277:53)
      at async loadAndTransform (file:///app/node_modules/vite/dist/node/chunks/dep-1513d487.js:39776:29)

Deps:

  • vue@2.7.7
  • vite@3.0.2
  • vue-class-component@7.2.6
  • vue-property-decorator@9.1.2
  • typescript@4.7.4

on Windows@11

Update

DEMO: https://stackblitz.com/edit/vue2-vite-starter-gkrjjz?file=src/components/Test.vue
Exporting an interface in combination with the string 'defaultXXX' inside a comment shows the error.

I assume that this line is causing the error:
at genScriptCode (\app\node_modules\@vitejs\plugin-vue2\dist\index.cjs:2993:37)
Code
scriptCode = options.compiler.rewriteDefault(script.content, "_sfc_main", [...defaultPlugins, ...userPlugins]);

@ammartinCIC
Copy link

+1

@ZeroThe2nd
Copy link
Contributor

Also happening for me, but with Vite version v2.9.14, and Vue version v2.7.8.

@CreMindES
Copy link

CreMindES commented Aug 15, 2022

I can also reproduce this on

  • Vue 2.7.8
  • Vite 3.0.7
  • @vitejs/plugin-vue2 1.1.2

Seems to be related to

as when moving the default export [className] after the class declaration, everything works nicely.

@rs3d
Copy link
Author

rs3d commented Sep 7, 2022

After updating to vue@2.7.10 the issue is gone:
https://stackblitz.com/edit/vue2-vite-starter-th6fyw?file=package.json

@CreMindES This might had fixed it in 2.7.9 according to the changelog:
vuejs/vue#12747

@rs3d rs3d closed this as completed Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants