You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Plugin looks great, resolves a few issues I have with the fastify-swagger plugin - Thanks!
In my local set up, I original had "module": "commonjs" but then after trying to use this plugin i get errors when i try to run locally with ts-node-dev.
Do you have a workaround with this, otherwise can you use a module format more amenable to running with node? For example, heres the fastify-resty TS Config
There are several workaround, depending on how you run your code and depending on your tsconfig.json.
If using the import fastifyOpenapiDocs from 'fastify-openapi-docs' don't work out of the box, then you have to use the dynamic import statement, which returns a promise with your module:
constfastify=require('fastify')()import('fastify-openapi-docs').then(fastifyOpenapiDocs=>{fastify.register(fastifyOpenapiDocs,/* ... */)/* Continue your server bootstrap */})
Now, due to a Typescript bug, even the import might be transpiled to a require and result in a ERR_REQUIRE_ESM error, so in that case you have to use a second workaround:
// Workaround for https://github.com/microsoft/TypeScript/issues/43329const_importDynamic=newFunction('modulePath','return import(modulePath)')constfastify=require('fastify')()_importDynamic('fastify-openapi-docs').then(fastifyOpenapiDocs=>{fastify.register(fastifyOpenapiDocs,/* ... */)/* Continue your server bootstrap */})
Let me know if this works, otherwise please provide me a minimal reproduction repository.
Hope this helps!
Hey!
Plugin looks great, resolves a few issues I have with the fastify-swagger plugin - Thanks!
In my local set up, I original had
"module": "commonjs"
but then after trying to use this plugin i get errors when i try to run locally with ts-node-dev.Do you have a workaround with this, otherwise can you use a module format more amenable to running with node? For example, heres the fastify-resty TS Config
Links for issues related:
ts-node issue
stackoverflow post on issue
If you'd prefer a PR on this, let me know!
The text was updated successfully, but these errors were encountered: