-
Notifications
You must be signed in to change notification settings - Fork 38
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
Disparity between encoder and FF decoder #417
Comments
Actually, there are quite a few things that are not implemented Firefox side yet. Search for instances of So, unfortunately, no ETA just yet. While I don't have time to write that code myself just yet (maybe in August/September?), I'd be happy to review code that adds an option to restrict to what is currently implemented in Firefox. |
@Yoric Quickly looking at these instances, is it safe to say that ES5 is fully supported and it's just some ES6+ features that are not implemented? |
almost all ES5 feature are supported, except Function.prototype.toString() and block-scoped functions. |
@arai-a Hmm, will block-scoped function also throw a syntax error or just silently work differently than in the original JavaScript? |
It throws syntax error, due to scope mismatch. |
Sounds good (well, at least it's not a silent breakage). I'll look into filtering out AST nodes in the encoder for now then. |
Looks like at least lazy getters and setters (which are part of ES5) are also unsupported. Looking carefully for more, but it's hard to find all the cases from just C++ code... Having a separate list for tracking could be nice. |
@arai-a is there any reason not to fallback to parsing lazy methods/getters/setters as eager in Firefox until a proper implementation is added? |
mostly no reason I think, just that they got low priority, |
Yes, but currently encoder lazifies all of them, which, like with other mentioned cases, can lead to producing BinaryAST that won't be actually parseable. |
This issue is just particularly high-priority for CDN-wide testing, because, if we enable encoder by default on CDNjs or unpkg.com, then it can currently break lots of assets with no way of us knowing about that or being able to fix it. I'm currently trying to filter out nodes by looking at Firefox C++ code, but it still feels pretty risky... |
for multipart, we can treat lazy function as eager function, given the function body is stored in-place. but that doesn't apply for context format, that stores lazy functions in the latter part of the file, separate from the enclosing script. so, if treating lazy getter as eager getter in multiplart format is high-priority, I think supporting that now is reasonable. do you have any deadline? |
No, it's not particularly that part that is high-priority but the general "we have things produced by the encoder that are not recognised by decoder" issue. I guess it won't go away until BinASTParser supports all the nodes... |
Currently trying to encode JavaScript that uses ES6
const
syntax succeeds, but then trying to load the result in Firefox fails with:While the encoder is in theory generic and shouldn't be tied to what's implemented on the Firefox side, this can currently lead to pretty bad cases where we serve a transformed JavaScript that consequently fails in Firefox with no reasonable fallback.
I'm not sure how much work is there to finalise the Firefox decoder side, but should we consider restricting the encoder to transform only features supported on both sides and throw an error otherwise?
Also, are there other known cases that are supported in the encoder but not decoder?
cc @xtuc @Yoric @arai-a
The text was updated successfully, but these errors were encountered: