dohomi / storyblok-generate-ts

Generates TypeScript interface types based on Storyblok component file
MIT License
102 stars 33 forks source link

Package does not work with `prettier-plugin-astro` #54

Closed jsve closed 10 months ago

jsve commented 1 year ago

I'm having an issue when using your package together with prettier-plugin-astro. Using storyblok together with Astro seems like a pretty common use case, hence I think this makes sense to do something about.

After installing prettier-plugin-astro I get this error when running: storyblok-generate-ts source=./components.XXX.json target=./src/storyblok-components compilerOptions.bannerComment=\"// GENERATED FILE. DO NOT EDIT MANUALLY\"

The error I get is: ERROR Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/user/github/repo/node_modules/prettier-plugin-astro/dist/index.js from /Users/user/github/repo/node_modules/prettier-plugin-astro/dist/index.js in /Users/user/github/repo/node_modules/prettier/index.js to a dynamic import() which is available in all CommonJS modules.

The result is that the generated d.ts includes only one line: import {StoryblokStory} from 'storyblok-generate-ts'

removing prettier-plugin-astro from package.json and running yarn install generates the d.ts as expected.

dohomi commented 1 year ago

I am not using the plugin neither astro. I'm happy to merge any PR solving this issue but I won't have the time to dig into it.

jsve commented 10 months ago

Closing this, as I believe the issue was on my end. Something related to having multiple different prettier versions in the mono-repo and some bug regarding which version was picked up by the astro plugin.

Sorry for the confusion!