Closed nobleach closed 2 years ago
To be fair, the readme shows using .js
, not .ts
. The reason TypeScript don't work here is that in development mode the entry
is imported when the server is being configured and is imported directly from Node.js, not from within Vite. So you don't get any of Vite's features such as TS.
Since this file does wind up part of your build it would be better if this file were imported by Vite in dev mode. I'll have to see the practicality of doing that, but it's definitely a nice to have. Thanks for reporting!
I'm trying to decide if this is just a documentation issue or if there's something else going on. Starting a brand new Astro project via
npm create astro@latest
and then attempting to add this dependency, throws an error:Well that's simple enough, right? We named the file
api/index.ts
. So, let's change that in the config:But that'll throw:
As we're trying to us ESM imports, not Typescript. So let's try naming the file
index.js
. From the presence of a type definition, it looks like you really did mean for it to be Typescript though. Regardless, that doesn't work.Finally, let's name the file
.mjs
and change the reference to./api/index.mjs
. THAT seems to work. I don't think that was your intention though. I really do think you wanted to use Typescript so... what might I be missing here?