zoubingwu / msw-auto-mock

A cli tool to generate random mock data from OpenAPI definition for msw.
246 stars 54 forks source link

Error [ERR_REQUIRE_ESM] when use with prettier-plugin-tailwindcss. Can you update prettier to v3? #41

Closed shatynska closed 7 months ago

shatynska commented 7 months ago

Hi! First of all, thanks for your library, it really helps me a lot. However, I found out that when I used prettier-plugin-tailwindcss, it caused errors.

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

My research has led to a hypothesis that it is because of the version of Prettier in your lib.

As @thecrypticace in tailwindlabs wrote

That script is using Prettier 2 to format files and we only support Prettier 3, and Prettier 2 autoloads plugins, and Prettier 2 does not support ESM. Only require() / CJS.

I think there are related issues from other libs:

Is it possible to update the prettier version from 2 to 3? Thanks in advance!

WakuwakuP commented 7 months ago

I'm also experiencing this issue.

zoubingwu commented 7 months ago

@shatynska @WakuwakuP Hey this should be fixed in 0.18.0 pls upgrade and try it again.