-
Notifications
You must be signed in to change notification settings - Fork 851
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
Question: Is there a recommended version of babel preset env to use when transpiling down ES2020 features? #661
Comments
I have a fantasy that someone could not only figure out the ideal
configuration of Babel to make Rhino work best, but then help us understand
what things Babel can't do so that we can focus Rhino feature development
on them.
For instance if Babel can do a reasonable approximation of Promises, but it
is not nearly as useful without built in Rhino support, then someone could
focus on that.
…On Wed, May 6, 2020 at 12:59 AM swarajgiri ***@***.***> wrote:
In case we have, can we add a recommendation in the documentation?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#661>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAD7I2YPVB4WRHUTHILWTW3RQEKGVANCNFSM4M2G5ZBA>
.
|
@gbrail do you have the code to run the compat table generation somewhere? I am currently trying to figure out whether we could somehow mash that together with babel's preset-env to get an automatically updating preset. |
Yes! https://github.com/gbrail/node-compat-table The "rhinotest.sh" script is the script that's adapted to run against Rhino, and "rhinoall.sh" builds the full table from scratch with all the versions. It's probably a bit behind, and missing some docs, but if you are able to use it for something useful then that'd be great! |
Amazing! In the root repository for that fork, they said they'd accept PRs for updated results for Rhino - would you be willing to provide those from your work here? That would mean that EDIT: I spoke too soon. It seems that while |
That document tells that Babel doesn't run in Rhino, but you can still use Babel to produce code that runs in Rhino. This is not going to change (you'll need Node.js to run Babel). However, we can add Rhino as a valid |
Oh that's fantastic, thank you so much for the clarification @nicolo-ribaudo. There is already compatibility information for |
@nicolo-ribaudo is there anything you need help with on that? I've written a quick and dirty compat-table test runner script for rhino to update the compat-table data files if that's useful. (rhino 1.7, the latest with data in compat-table, is very out of date, but of course adding support for that would work for later versions). |
Updating the data in
|
I updated @gbrail this might be of interest to you! |
@gausie Nice work! Is it reasonable to assume that e4x will not be supported when compiling to Rhino with Babel? https://www.ecma-international.org/publications-and-standards/standards/ecma-357/ React's JSX is based on e4x, but e4x has additional syntax and would need to remain unaltered in the compiled source. For a long deprecated standard, it still gets heavily used in https://github.com/nextgenhealthcare/connect |
@gausie also not sure about calling the version All of the versions in https://mozilla.github.io/rhino/compat/engines.html are different |
It looks like it can do so with an extra plugin! Babel has a package called
Very good point, this is just a follow-on from the small amount of Rhino support that already existed using |
I just looked into the extra plugin you mentioned, but it looks like it's specifically for transpiling JSX compatible xml literals to code to be used with this library https://github.com/pikamachu/pika-simple-e4x. It even requires The JSX syntax plugin might be a good starting point, but there would be quite a bit more to do. Just on the literal side, JSX does not support xml namespaces. The following are all valid syntax in true e4x. var a = x.*; // wildcard support for all child elements
var a = x..b; // descendants operator
var a = x.(b == c); // filter syntax
var a = x.b::c; // explicit namespace syntax
var a = x.*::c; // also supports wildcards for namespaces
var a = x.@b; // attribute accessor
for each (var a in x) {} // xml list iteration
default xml namespace = 'uri:some/namespace'; // set default namespace I've never used Babel before, but I assume all of that would cause the parser to choke, even with the JSX plugin. |
I have no idea what e4x is or why what you've posted doesn't work sorry. |
@gausie That's ok. I wasn't expecting you to have an answer. I was mostly documenting what Babel would need to support if someone wanted to use it to compile javascript that contained e4x code. I just tested the code in the Babel repl online and the XMLList literal syntax actually did work with the I included a link to the specification in a previous comment. https://en.wikipedia.org/wiki/ECMAScript_for_XML |
@gausie nice work! Quick question: would this babel preset take into account the non-standard const implementation or the not fully spec-compliant let implementation and down-compile those all to vars? BTW: once the Babel preset for Rhino is available, I think we should add its existence and how to use it somewhere in a README |
It entirely depends on which of their unit tests our const and let
implementations pass
…On Tue, 22 Jun 2021, 08:04 Paul Bakker, ***@***.***> wrote:
@gausie <https://github.com/gausie> nice work!
Quick question: would this babel preset take into account the non-standard
const implementation or the not fully spec-compliant let implementation and
down-compile those all to vars?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#661 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABL4LWAXNJYMPTLP3N5R4DTUAYWLANCNFSM4M2G5ZBA>
.
|
Looks like it just down-compiles them all to |
Nice! |
@gausie I see babel/babel#13448 got merged. What is the status of this case now? And what are the steps to take once v1.7.14 gets released? |
Babel regularly pulls compatibility data from github.com/kangax/compat-table, so when Rhino has new features they should be marked there as supported. |
Tnx @nicolo-ribaudo So the question becomes: what is needed to update the compat-table with the results based on the upcoming release? Or does compat-table somehow automatically pick up the latest Rhino release? |
It needs to be done manually, but I think @gausie wrote a test runner to help doing it. This is an example of what a "new engine version" PR looks like: compat-table/compat-table#1766 |
Yep! There's a |
I think we can close this issue too as you just need to specify |
Note that even if we waited for a minor Babel release to add Rhino support, simple version updates can land in patches (which we release way more frequently). |
So if I understand correctly:
If that is correct, I'll close this case, add something related to this to the 1.7.14 release notes and create a case to get it documented how to update the compat tbale and Babel after a new Rhino release |
@gausie Is my summary in the comment above correct? |
@p-bakker don't forget updating |
@zloirock I have no insight into the process at all, so if you say 'core-js compat data' need to be updated, I gladly believe you, but have no idea what that entails :-) Thats why I'm asking for clarification in #661 (comment). Assume the updating of core-js compat data is part of what I referred to as "@gausie can do some magic" |
@gausie Rhino 1.7.14 has been released, so whatever needs updating can now be updated from 1.7.13 to 1.7.14. Is that something you're willing to pick up? Regardless of whether you can pick up that task or not, I think it would be benefitial for all if the required steps can be documented, so for future releases it can become part of the release steps. Could you share the steps involved? Or even a PR to add the info to https://github.com/mozilla/rhino/blob/master/RELEASE-STEPS.md? |
@p-bakker I'll look at doing that this weekend and I'll document the steps as I go. |
Closing as the process how to update the babel & the compat table is now documented |
In case we have, can we add a recommendation in the documentation?
I am mostly interested in babel preset for rhino version 1.7.7.1
The text was updated successfully, but these errors were encountered: