-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix(compiler-sfc): analyze export default by AST #7068
Conversation
❌ Deploy Preview for vuejs-coverage failed.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@znck Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A problem with this approach: rewriteDefault
is used in @vitejs/plugin-vue
here, on the script string already transformed by compileScript
. This means the string no longer matches the Node positions in the AST exposed on the SFC descriptor.
I think we need to do something similar to reactivity transform's transformAST
:
- Accept both the AST and the corresponding MagicString instance in
rewriteDefault
- Also expose the MagicString instance on the script block returned by
compileScript
- In
@vitejs/plugin-vue
, feature detect by checking whether MagicString instance is available
- If yes, use AST-based rewrite by passing in AST + MagicString
- If no, fallback to old usage
@sxzz did you end up re-creating vitejs/vite#10888 for https://github.com/vitejs/vite-plugin-vue? |
@yyx990803 No, I haven't done it yet. |
…f regex (vuejs#7068) closes vuejs#7038 closes vuejs#7041 closes vuejs#7078
closes #7038, closes #7041, closes #7078
vite plugin PR vitejs/vite#10888
thanks to @btea