UnrefinedBrain / vue-metamorph

Codemod Framework for Vue projects
https://vue-metamorph.dev/
MIT License
71 stars 1 forks source link

`generic` causing error #116

Closed zernonia closed 1 week ago

zernonia commented 1 week ago

Hey @UnrefinedBrain ! Really glad that you made this library, and it has been super easy to use! I'm implementing the code transformation for shadcn-vue however I run into issue with SFC with generic.

Steps to recreate:

  1. Transform a SFC string with generic="T extends Record<string, any>"
  2. Observe error Cannot read properties of undefined (reading 'length')

Edit: After digging deeper, seems like vue-eslint-parser issue, however I'm not sure if it's the parser config issue

UnrefinedBrain commented 1 week ago

Seems to be a small AST difference between @babel/parser and @typescript-eslint/parser, which is fixed by https://github.com/babel/babel/pull/12829

However, Babel 8 has not yet released. I'll try some things to work around it

UnrefinedBrain commented 1 week ago

I opened a PR for vue-eslint-parser to fix this issue: https://github.com/vuejs/vue-eslint-parser/pull/236

UnrefinedBrain commented 1 week ago

vue-eslint-parser maintainer doesn't want to merge the change. We can either use an alpha version of babel 8 or make a local patch for vue-eslint-parser

I think for now I will do a local patch, and update to babel v8 as a real fix once it releases.

update: bundling local patch is harder than I thought. Maybe we need to use alpha version after all

UnrefinedBrain commented 1 week ago

I published 3.1.13 which should hopefully fix this issue by upgrading babel to v8. at least, my test case is passing now.

Can you let me know if it worked for you?