IanVS / prettier-plugin-sort-imports

An opinionated but flexible prettier plugin to sort import statements
Apache License 2.0
984 stars 25 forks source link

Detect vue 2.7 / 3 more reliably #160

Closed IanVS closed 6 months ago

IanVS commented 6 months ago

Fixes https://github.com/IanVS/prettier-plugin-sort-imports/issues/158

The transformRef method is not found on the most recent versions of @vue/compiler-sfc (3.4.x), because it seems to have only existed for some versions of 3.x (including the version we use in devDependencies, which is why our tests passed). I couldn't find any mention of it in the Vue changelog, though it seems like it should have been a breaking change to remove the method.

So, now instead of relying on the presence of a method, we'll import the package.json directly, look at the version field, and make our decision based on that, which should be much safer.