-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
fix(reactivity-transform): ensure that macros comply with the original semantics (#6312) #6944
Conversation
❌ Deploy Preview for vuejs-coverage failed.
|
nice! |
@sxzz hi guys, do u have a minute to review this pr? |
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.
wow😮..... thx, i can to retain the expressions in brackets. but, this sence really exists and make sense in unref? |
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.
Still error... It's a pretty troubling example.
https://deploy-preview-6944--vue-sfc-playground.netlify.app/#eNqlUMtOwzAQ/BXL6gHU2OFQIREKEv/hS0i2JciP1XqTKory76wbhBAce/M8PDPaRb8h2mkE3ehj7mhAVhl4xFcXPbDq0hhZvaiHZxe7FHPyYH063135exd3u+2531ebV7hjvQVJhACGgL5lEKTUsiiCPHpW61qMP6Ku9BAwEZvQov3MKcqgpXxx30J2ulFXpnCyuGCnP5gxN3XdA/o0GySYBriYx6fDwRhxmXzqjHTMZ5J5vY3AfjjNtkWsRbYkm4cAFnIw75QuGUjqna5+NdVCTkCGIPZAQLc3/wn8117K5UCrXr8ABJKTFw==
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.
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.
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.
😅 Such a huge number of edge cases. We should also handle spaces.
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.
🙇🏻 Sorry, but...
Another case
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.
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.
❤️ Great! Thanks for your contribution!
Could you please add more tests about the examples I provided?
i think the current tests should already cover all for you provided ? |
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.
LGTM, thanks!
hi, it seems to be forgotten 😭 , could you request a maintainer to approve or review it? (first-time contributor 👀 |
Please be patient, just wait. |
# Conflicts: # packages/reactivity-transform/__tests__/__snapshots__/reactivityTransform.spec.ts.snap
# Conflicts: # packages/reactivity-transform/src/reactivityTransform.ts
@yyx990803 hi, the code-style issues and conflict has been solved |
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.
Could you please revert the format commit? (Just run pnpm run format
to fix that)
It causes lots of unrelated changes.
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.
LGTM
Thanks a lot for the PR and the discovery of the edge cases. However the implementation here is missing the root cause of the problem, leading it to be unnecessarily complicated. The missing semicolon issue only arises when the CallExpression is the first thing on a newline. This means
With that we already rule out many of the edge cases this PR is attempting to account for. The only remaining case is avoiding the semi insertion when there are non-whitespace between CallExpression and the previous newline. I reused the test cases from this PR to ensure all cases found here are covered. |
s.remove(node.callee.start! + offset, bracketStart) | ||
|
||
if (node.arguments.length === 1) { | ||
const bracketEnd = node.arguments.at(-1)!.end! + offset |
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 side note: Array.prototype.at
is only available in Node 16.6+.
Even in Node-only code branches we need to be conservative about using new language features since this can implicitly break user builds running on Node versions below 16.6.
unwrap the code form the macro($()、$ $())
$$
breaks the original semantics #6312code:
now:
RFC & after fix: