Skip to content
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

babylon is outdated as a js parser #3155

Closed
jomadel opened this issue Feb 3, 2023 · 5 comments · Fixed by #4589
Closed

babylon is outdated as a js parser #3155

jomadel opened this issue Feb 3, 2023 · 5 comments · Fixed by #4589
Milestone

Comments

@jomadel
Copy link

jomadel commented Feb 3, 2023

When I execute the basic example for code generation from https://redux-toolkit.js.org/rtk-query/usage/code-generation for a javascript-environment, I get:


npx @rtk-query/codegen-openapi openapi-config.js
Generating petApi.js
ConfigError: Couldn't resolve parser "babylon"
at requireParser (C:\temp\openapi-test\openapi-test\node_modules\prettier\index.js:6616:15)
at resolveParser (C:\temp\openapi-test\openapi-test\node_modules\prettier\index.js:7497:16)
at normalize (C:\temp\openapi-test\openapi-test\node_modules\prettier\index.js:7741:22)
at formatWithCursor2 (C:\temp\openapi-test\openapi-test\node_modules\prettier\index.js:9006:50)
at C:\temp\openapi-test\openapi-test\node_modules\prettier\index.js:38168:12
at Object.format (C:\temp\openapi-test\openapi-test\node_modules\prettier\index.js:38182:12)
at prettify (C:\temp\openapi-test\openapi-test\node_modules@rtk-query\codegen-openapi\lib\utils\prettier.js:53:21)
at async generateEndpoints (C:\temp\openapi-test\openapi-test\node_modules@rtk-query\codegen-openapi\lib\index.js:21:87)
at async run (C:\temp\openapi-test\openapi-test\node_modules@rtk-query\codegen-openapi\lib\bin\cli.js:59:13)

The issue seems to be that in @rtk-query\codegen-openapi\lib\utils\prettier.ts
there is a config array which defines the parser for each file type like so:


const EXTENSION_TO_PARSER = {
ts: 'typescript',
tsx: 'typescript',
js: 'babylon',
jsx: 'babylon',
'js.flow': 'flow',
flow: 'flow',
gql: 'graphql',
graphql: 'graphql',
css: 'postcss',
scss: 'postcss',
less: 'postcss',
stylus: 'postcss',
markdown: 'markdown',
md: 'markdown',
json: 'json',
};

It seems that
babylon
is no longer the valid parser for js or jsx-files. Instead babel should be used.

@jomadel
Copy link
Author

jomadel commented Feb 3, 2023

Also cmp. #1795 by the way.

Best regards,
jomadel

@markerikson markerikson closed this as not planned Won't fix, can't repro, duplicate, stale Dec 6, 2023
@markerikson markerikson reopened this Dec 6, 2023
@markerikson markerikson added this to the Post 2.0 milestone Dec 6, 2023
@johnmorton503
Copy link

I was just trying to give RTK a try/ evaluation for use, this was pretty much the first thing I ran into. Has put a lot of doubts in my mind, is this package still considered relevant and being actively maintained for example. That is a pretty old version of Prettier there.

@markerikson
Copy link
Collaborator

markerikson commented Jan 3, 2024

It's on our list to address, but we shipped RTK 2.0 right before the holidays, and none of us have had free time to do any real RTK work in the last month due to holidays and family time.

(Note that RTK itself is fine - this is just about the RTKQ codegen.)

@phryneas
Copy link
Member

phryneas commented Jan 3, 2024

In the past, this was only a problem when formatting .js files, which the codegen cannot generate anyways, since it always generates .ts files.
If that has changed with prettier 3, would you be willing to submit a PR to update prettier and change these settings?

@markerikson
Copy link
Collaborator

Should be live in https://github.com/reduxjs/redux-toolkit/releases/tag/%40rtk-query%2Fcodegen-openapi%402.0.0-alpha.0 ! Please try it out and let us know if it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants