Skip to content

chore(compiler-sfc): specify prettier version (fix #13052)

Created by: ShGKme

close: #13052 (closed)

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:

@vue/compiler-sfc optionally uses Prettier and it is not compatible with Prettier v3.

But prettier is not listed in the package.json.

It wasn't a problem with Prettier v2 because prettier is optional dependency of component-compiler-utils. So Prettier is installed anyway and everything works.

But if some project has Prettier@3, then @vue/compiler-sfc uses project's prettier and fails.

There was the same issue early in component-compiler-utils. See:

This PR specifies Prettier as an optionalDependency of @vue/compiler-sfc. With specified dependency, it will use prettier@2 even if a project has prettier@3.

P.S. I used the same versions as it was in the component-compiler-utils. It seems it has the same code.

Alternative solution: make @vue/compiler-sfc compatible with both Prettier@"1 || 2" and Prettier@3. The problem is that it will make the compile function async.

Merge request reports