-
Notifications
You must be signed in to change notification settings - Fork 482
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
Add support for Babel 7 #996
Comments
Customarily I wait until projects are in stable release state to update to them (babel 7 is still a beta). That said, if anyone wants to help out and write a PR for this issue (or any other!) happy to review & merge. |
I have tried to migrate on new babel version, but in babelify source hardcoded uses babel 6 version. it is blocking for us. waiting PR babel/babelify#255 |
@anthony-redFox |
That's great news! Setting a reminder to check back on Friday and start a migration if it's landed. |
Any update on this? |
@suparng-medallia I believe #1114 has some more info on progress related to the upgrade |
Sorry for the delay on this issue, folks - it's in my TODO to review, merge, and deploy documentation.js with babel 7 support this afternoon (PST), assuming everything goes according to plan. |
All right - documentation.js |
I’m having issues with the alpha due to Babel configuration—we use legacy decorators and the syntax @foo
export default class Cls { /* ... */ } This is not supported by the default Babel configuration, which demands that the export default @foo class Cls { /* ... */ } Thus, running
It does not seem to be possible to pass any configuration to Babel via documentation/src/parsers/parse_to_ast.js Line 14 in 49c0f72
Might it be possible to read Babel config from the target directory, or at least pass customised options via |
Was that working in documentation.js before the v7 support? I'm a little hesitant to add another option to the parser, this project is already awash in options to handle different edge cases. |
I’m not too sure; a variety of things weren’t working before… While I take your point about edge cases, I wonder if this should really be considered as one. The ideal, IMO, would be to use the configuration of the project you’re running against. I expect that this would be most useful to most users—surely accepting the same syntax at build time and doc generation time is what most users would want and expect? When would that not be the right choice? |
Sure, well - mostly because documentation.js is able to parse a variety of syntax forms, but opening the door to every possible syntax plugin means that it will then see ASTs that aren't handled at all in the inference stage, and that'll be logged as a bug. Given an ever-expanding set of plugins, that would put documentation.js in the position of having to support every possible plugin, every plugin one-by-one, or setting some sort of limit. Which - I'm totally down with, if there's the contributor energy to do it, but I'm not confident that a user who just needs to run the tool just once with plugin X will invest the time making it work, rather than dropping a bug report. At least in the medium-term future, I'm really leaning toward building tools that work with certain standardized subsets of the bleeding edge, like 'only stage 4 proposals', for example. Which cuts out a lot of users who are really pushing the babel toolchain to its limits, but allows me as a maintainer to focus on building a great thing solving the problem, rather than handling syntax variants. |
I definitely don’t know the internals of Babel’s ASTs, so I may just be speaking out of ignorance. Do syntax plugins generate invalid ASTs (from the POV of code that isn’t aware of it)? I guess my implicit assumption was that if a Babel syntax plugin consumes novel syntax, it would either generate a standard AST, or a subtree that you could shrug at and say “Well, that’s not supported”. For example, I figured that the decorator syntax plugin would generate the same AST albeit based on slightly different inputs. I mean, I for one wouldn’t assume that the tool would necessarily document my use of decorators; I just didn’t expect it to puke a syntax error. But of course, (we) users can be a pain sometimes… |
Add an extra wrinkle: Our project uses https://prettier.io/, which I gather is fairly popular. I experimentally reversed the order of decorators and export, and found that Prettier corrects it back to the legacy format. Presumably, then, enforcing export-before-decorators will break any project using Prettier. |
@haggholm I have the same issue |
I got it to work by patching |
All right - custom babel configurations are now supported in 10.x like
We may support auto-resolving babel configs in the future with a 11.x, PRs gladly accepted in that direction. |
As of today, having a
.babelrc
file with the preset@babel/preset-env
makes thedocumentation build
command throw an error.The text was updated successfully, but these errors were encountered: