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

chore: upgrade babel parser version #153

Closed
wants to merge 1 commit into from

Conversation

zxt-tzx
Copy link

@zxt-tzx zxt-tzx commented Mar 11, 2024

hello, bumping up the babel parser version because I am using prettier-plugin-sort-imports in my codebase and using latest using syntax resulted in a Prettier error

I poked around and found out it's because this syntax is is supported only since v7.22.0 of babel: see https://babeljs.io/blog/2023/05/26/7.22.0

thanks!

@IanVS
Copy link
Owner

IanVS commented Mar 11, 2024

Hi, thanks for the contribution. We don't use the using syntax and we don't pin our version of Babel like the trivago project does. So if you need to use a version of babel that is more recent than you have now, you should be able to just update your lockfile (either by deleting it and your node_modules and re-installing or by using a pnpm.overrides, or resolutions, or whatever your package manager requires.

I'll work on releasing a version soon that updates babel, but in the meantime at least you shouldn't be blocked.

@IanVS IanVS mentioned this pull request Mar 11, 2024
@zxt-tzx
Copy link
Author

zxt-tzx commented Mar 11, 2024

Thank you for working on this and taking the time to reply! I'm not very familiar with how to override this and unblock myself.

This is the error message I get from Prettier:

["ERROR" - 20:05:42] Error formatting document.
SyntaxError: This experimental syntax requires enabling the parser plugin: "explicitResourceManagement". (28:2)
    at constructor (/Users/xxx/project/node_modules/@ianvs/prettier-plugin-sort-imports/node_modules/@babel/parser/lib/index.js:356:19)

What I've done:

  1. added "overrides": { "@babel/parser": "^7.24.0"} to pnpm under package.json
  2. installed and added '@babel/plugin-proposal-explicit-resource-management' to the plugins in prettier.config.cjs
  3. deleted and reinstalled my node_modules

however, I'm still getting the error from Prettier.

Would appreciate any tips, thank you so much for working on this and taking the time to reply!

@IanVS
Copy link
Owner

IanVS commented Mar 11, 2024

Ah, thanks for sharing the error. It sounds like you need to add explicitResourceManagement to importOrderParserPlugins in the prettier config. If that doesn't work, would you mind opening an issue and sharing your prettier config so I can help troubleshoot there?

@zxt-tzx
Copy link
Author

zxt-tzx commented Mar 11, 2024

Ah, thanks for sharing the error. It sounds like you need to add explicitResourceManagement to importOrderParserPlugins in the prettier config. If that doesn't work, would you mind opening an issue and sharing your prettier config so I can help troubleshoot there?

will do, thank you so much!

@zxt-tzx
Copy link
Author

zxt-tzx commented Mar 11, 2024

oh wait, after updating all the related dependencies and adding explicitResourceManagement to importOrderParserPlugins in the prettier config, the error has gone away.

no need for anything else (overriding or installing @babel/plugin-proposal-explicit-resource-management).

thank you so much! will close this now.

@zxt-tzx zxt-tzx closed this Mar 11, 2024
IanVS added a commit that referenced this pull request Mar 12, 2024
This updates babel in our `dependencies` to be sure that folks are
getting the most up-to-date version that supports new syntax like
`using` (closes
#153).

I also re-generated our `yarn.lock` because I was getting some type
errors, and removed `sourceFile` in one spot because it's no longer
needed and throws a TypeScript error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants