-
-
Notifications
You must be signed in to change notification settings - Fork 8
ES Modules + auto-load + node-ts #1014
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Try the below command to start. |
Yea it .. works..!??.. Thanks. I converted my repo to a demo repo which for now includes the workaround. Anyhow, nobody mentioned Is this a workaround on a workaround? Because I'm definitely not using Vitest test framework as you can see in my repo above... |
It seems in the Fastify auto-loader code it forces ES modules? Then the hooks & plugins will use this to force ESM. Why this isn't working without forcing this option (aka auto detect we're using ESM), I dunno. Hopefully you could tell. |
I am traveling right now, not much time to handle it It need a refactoring on the require/import handling. |
I see. Since you locked fastify/fastify-autoload#309 you might want to add this Otherwise others believe it's their fault as well, while actually you need another workaround (VITEST) when you use ESM with Fastify autoload. Have a nice trip! |
Uhm, I will reopen this item until the workaround is mentioned in ticket fastify/fastify-autoload#309, otherwise you might forget it. |
It has been updated through edit comment yesterday. |
💬 Question/problem here
In issue #309 of autoloader which I try to follow (eg.
FASTIFY_AUTOLOAD_TYPESCRIPT
) @climba03003 mentioned that if you still have issues, you configured your project incorrectly.However, I'm pretty sure my code works without fastify-autoload on routes directory. And I'm also sure I use
type": "module"
in package.json and"module": "NodeNext"
intsconfig.json
with target ES2022 and ts-node module configuration with:And even using the
FASTIFY_AUTOLOAD_TYPESCRIPT=1
flag like so:npm start
which will usetsc
will work fine!However running the command above (for example via
npm run dev
), this results into:Demo GitHub repository for the reproduction code: https://github.com/melroy89/fastify-node-ts-issueDemo GitHub repository that now contains the workaround
VITEST
: https://github.com/melroy89/fastify-node-ts-swc-demoCode in question:
So you can test it for yourself, again see github repo above.
Please some help or advise would be much appropriated! ❤️ . I would like to integrate Fastify further into my applications and still being able to use
node-ts
for rapid software development.Your Environment
The text was updated successfully, but these errors were encountered: