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

Release prettier dependency update #269

Open
oliviertassinari opened this issue Dec 24, 2024 · 2 comments
Open

Release prettier dependency update #269

oliviertassinari opened this issue Dec 24, 2024 · 2 comments

Comments

@oliviertassinari
Copy link

oliviertassinari commented Dec 24, 2024

  • babel-plugin-tester version: 11.0.4

Relevant code or config, What you did:

module.exports = {
  printWidth: 100,
  singleQuote: true,
  trailingComma: 'all',
  plugins: ['prettier-plugin-tailwindcss'],
}

What happened:

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/oliviertassinari/material-ui/node_modules/.pnpm/[email protected][email protected]/node_modules/prettier-plugin-tailwindcss/dist/index.mjs not supported.
Instead change the require of /Users/oliviertassinari/material-ui/node_modules/.pnpm/[email protected][email protected]/node_modules/prettier-plugin-tailwindcss/dist/index.mjs to a dynamic import() which is available in all CommonJS modules.

Problem description: prettier-plugin-tailwindcss is an ESM only package, proof: https://unpkg.com/prettier-plugin-tailwindcss/package.json, but babel-plugin-tester@latest depends on:

"prettier": "^2.8.3",

The problem is that support for ESM plugin comes only later on https://prettier.io/blog/2023/07/05/3.0.0.html#support-plugins-in-esm-13201httpsgithubcomprettierprettierpull13201-by-fiskerhttpsgithubcomfisker.

Suggested solution: Can we publish a new version?

https://github.com/babel-utils/babel-plugin-tester/releases/tag/v12.0.0-canary.1 solved the problem, but it's unstable.

@Xunnamius
Copy link
Collaborator

Xunnamius commented Jan 3, 2025

Hey @oliviertassinari, thanks for the report! And I feel your pain :)

I would very much like to release babel-plugin-tester@12, which includes prettier@3 and jest@30 support, but there are two blockers:

1. BPT integrates snapshot support from Jest. The guarantee is: if you're using Jest, BPT can use Jest's snapshots. However, prettier@3 requires jest@>=30 or snapshot functionality breaks. Further, jest@30 is currently in pre-release and the majority of Jest users are not using it.

These facts alone aren't very interesting, and having a non-canary babel-plugin-tester@12 require jest@>=30 while the older babel-plugin-tester@11 maintains support for jest@<30 was my original plan. The problem is this:

$ npm install --force 
npm warn using --force Recommended protections disabled.
npm warn ERESOLVE overriding peer dependency
npm warn While resolving: [email protected]
npm warn Found: [email protected]
npm warn node_modules/jest
npm warn   peerOptional jest@">=30 || >=30.0.0-alpha.2" from the root project
npm warn   2 more (eslint-plugin-jest, @-xun/symbiote)
npm warn
npm warn Could not resolve dependency:
npm warn peerOptional jest@">=27.2.5" from [email protected]
npm warn node_modules/jest-extended
npm warn   dev jest-extended@"^4.0.2" from the root project
npm warn   1 more (@-xun/symbiote)
npm warn
npm warn Conflicting peer dependency: [email protected]
npm warn node_modules/jest
npm warn   peerOptional jest@">=27.2.5" from [email protected]
npm warn   node_modules/jest-extended
npm warn     dev jest-extended@"^4.0.2" from the root project
npm warn     1 more (@-xun/symbiote)

To use babel-plugin-tester@12 with jest@>=30 and the rest of the Jest ecosystem (like jest-extended) requires adding --force to npm install. While this may be acceptable for my own projects, it is unacceptable to force downstream consumers to use --force. And since babel-plugin-tester was originally conceived to work with Jest (and I quite like Jest), abandoning Jest is not an option.

I've also looked into package.json overrides, which seem like they should solve this, but they're (1) not globally supported among all package managers and (2) seemingly broken.

So the first blocker is: we're waiting on jest@30 to be released. They're likely accepting PRs 😄

2. Technically, babel-plugin-tester@12's minimum supported Node.js version is 20 (though it still works for downstream consumers using node@18). node@18 has until May 2025 before it falls out of long-term support range. This fact alone wouldn't normally stop me from publishing babel-plugin-tester@12 (node@<=18 users would just stick with version 11), but combined with the rigmarole surrounding jest + prettier + npm install --force, it seems prudent to wait for now.

Though, I am open to suggestions.

@Xunnamius
Copy link
Collaborator

Xunnamius commented Jan 3, 2025

That said, I'm about to cut a new release of BPT ([email protected]) with tests passing on both Windows (10 and WSL) and Linux (Ubuntu) any day now.

Suggested solution: Can we publish a new version?

https://github.com/babel-utils/babel-plugin-tester/releases/tag/v12.0.0-canary.1 solved the problem, but it's unstable.

The current canary shouldn't be unstable. It's only canary because of the foresaid blockers. Are you experiencing any issues with it (especially Windows-related)?

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

No branches or pull requests

2 participants