-
Notifications
You must be signed in to change notification settings - Fork 8
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
bad transform of fake this param #71
Comments
Ultimately the goal is to fix embroider-build#71 (which this commit does *not* do) While working on that I decided to refactor the existing import related code and add some commentary to help others understand how it works. This just moves code around without changing behavior.
(I looked into this with @zvkemp but the following conclusions are mine) Refer to the commentary in #72 for a primer on how this works. TL;DR My bottomline conclusion is that we are incorrectly using the hygiene code in SWC and need to do something else, probably roll our own much more narrower/targeted version
So, my conclusion is that I think the built-in hygiene stuff from SWC is a poor fit for what we want to do, and it both does too much and too little. I think we'll probably have to write our own visitors, loosely based on what We tried the obvious/naive thing of just implementing a |
Wouldn't it be enough to rename the identifiers that we introduced for template? |
That's "more or less" what I meant by "write our own visitors, loosely based on..." Yep, it's just all of those things, but done correctly, devil is in the details 😄 Yep, We just have to make sure we visit all the right types of identifiers to check for all the right types of scopes – blocks, functions, take into account In the case there is no existing import, then yes we just have to pick a name that doesn't collide with anything in the places where there is a template tag and the replacement name has to be collision free in all of the intermediate scopes as well. In the case where there is an existing import, it gets complicated real fast (but as I said, the existing SWC code also doesn't handle this correctly), especially when there are evals (which we basically guarantee there is going to be), because renaming the existing import name can break user code that relies on the 95% of the time it's basically doing a bunch of deep analysis to discover we don't have to do anything. 50% of the challenge is to do that analysis correctly, and the other 50% of the challenge is to make sure we handle the edge cases where we do have to do something. All said and done, we can maybe reuse 30% of the SWC code, but it's still helpful to have that code available as a guide, informing us what kind of nodes we need to care about for the purpose of the analysis, etc. All the potentially useful parts are already exported, so we don't really need to make changes in our fork. It's best to keep the code outside of the SWC tree as much as possible to make it easier to merge in upstream changes. Plus you don't really want to be messing around with changing something as core as this. If we can find overlapping availability considering timezone differences, would also be happy to pair on it. |
You mean there could be an eval which expects the |
Mayb would be enough to rebase swc on latest: Edit, looks like content-tag is already using v1.3.92 |
Haven’t had a chance to review in detail, but on the topic of it being
unusual to leave the typescript in the output: yes, it’s clearly a
less-tested use case and this is not the first bug I’ve found in that area.
But upstream swc definitely *intends* to support it and it’s probably a
small fix to make the hygiene system treat the `this` parameter as a type
and not a runtime identifier. That would be worth doing regardless of
whether or not we also have a bug in how we’re calling it.
I can merge upstream into our swc fork to make it easier to check if the
issue Patrick linked above definitely addressed our case.
…On Sat, Mar 2, 2024 at 3:46 AM Patrick Pircher ***@***.***> wrote:
Mayb would be enough to rebase swc on latest:
swc-project/swc#236 (comment)
<swc-project/swc#236 (comment)>
—
Reply to this email directly, view it on GitHub
<#71 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACN6MUI626HZ7QK5HNALRDYWGGVBAVCNFSM6AAAAABD7U4C56VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZUG4ZTEOJRGU>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
@patricklx see the comment here https://github.com/embroider-build/content-tag/pull/72/files#diff-a1f71e354ebbbb94c7534364ba0b92853eb124d48da73573fc10581ed9b940d6R13-R35 and the existing tests here https://github.com/embroider-build/content-tag/blob/main/src/lib.rs#L299-L350 to get up to speed on the cases we claim/aim to support |
for those who face the same issue, workaround can be found in https://github.com/cardstack/boxel/pull/1305/files#diff-3bde26507ee9a7a15f36481f9a8a61c93c006315047591bc9dab482a3b4b731dR156 |
results to
removing the
template
will make it work correctlyThe text was updated successfully, but these errors were encountered: