We are currently creating an integration for our APIs, and we get a "strange" error when building the dist folder using vite build , we have basically tried to look how storyblok integration did those solutions; because its similar and they do a great job!
It seems to be a typescript issue, but i have no idea why this appears (as f.e storyblok did the same). Running vite build give us:
components/BlockSlot.ts:1:23 - error TS2307: Cannot find module './BlockSlot.astro' or its corresponding type declarations.
1 import BlockSlot from "./BlockSlot.astro";
~~~~~~~~~~~~~~~~~~~
The BlockSlot.ts file
import BlockSlot from "./BlockSlot.astro";
export default BlockSlot;
and the corresponding BlockSlot.astro file
---
import FlyoNitroBlock from "./FlyoNitroBlock.astro";
interface Props {
slot: {
content?: object[]; // Add the content property with type object[]
};
}
const { slot } = Astro.props;
---
{slot?.content?.map((block: object) => <FlyoNitroBlock block={block} />)}
but in the package.json exports we have defined
"exports": {
"./BlockSlot.astro": {
"types": "./components/BlockSlot.ts",
"import": "./components/BlockSlot.ts",
"require": "./components/BlockSlot.ts"
}
}
the code is available: https://github.com/flyocloud/nitro-astro/tree/main/lib
tsconfig.json => https://github.com/flyocloud/nitro-astro/blob/main/lib/tsconfig.json
vite config => https://github.com/flyocloud/nitro-astro/blob/main/lib/vite.config.ts
package.json => https://github.com/flyocloud/nitro-astro/blob/main/lib/package.json
any help in any direction is very much appreciated.