fastify-cli icon indicating copy to clipboard operation
fastify-cli copied to clipboard

add experimental-strip-types in app-ts-esm

Open SimoneDevkt opened this issue 8 months ago • 4 comments

I modified the app-ts-esm template by inserting the indicated tsconfig https://nodejs.org/en/learn/typescript/run-natively#running-typescript-code-with-nodejs and erasableSyntaxOnly. This way the dev script can directly launch the ts file with --experimental-strip-types

Checklist

SimoneDevkt avatar Mar 06 '25 00:03 SimoneDevkt

Once strip types ships in Node v20, I'd recommend shipping a new version of this as a semver-major.

mcollina avatar Mar 08 '25 09:03 mcollina

Why is FASTIFY_AUTOLOAD_TYPESCRIPT=1 needed?

mcollina avatar Mar 08 '25 09:03 mcollina

Why is FASTIFY_AUTOLOAD_TYPESCRIPT=1 needed?

I tried to run it without this flag, but I got an error. I don't know why

Error: @fastify/autoload cannot import plugin at '***\fastify-cli\test1\src\plugins\sensible.ts'. To fix this error compile TypeScript to JavaScript or use 'ts-node' to run your app.
    at handleTypeScriptSupport (***\fastify-cli\node_modules\@fastify\autoload\lib\find-plugins.js:152:11)
    at processFile (***\fastify-cli\node_modules\@fastify\autoload\lib\find-plugins.js:124:3)
    at processDirContents (***\fastify-cli\node_modules\@fastify\autoload\lib\find-plugins.js:101:7)
    at buildTree (***\fastify-cli\node_modules\@fastify\autoload\lib\find-plugins.js:41:9)
    at async findPlugins (***\fastify-cli\node_modules\@fastify\autoload\lib\find-plugins.js:14:3)
    at async autoload (***\fastify-cli\node_modules\@fastify\autoload\index.js:20:22)

https://github.com/fastify/fastify-autoload?tab=readme-ov-file#override-typescript-detection-using-an-environment-variable

SimoneDevkt avatar Mar 08 '25 12:03 SimoneDevkt

https://github.com/fastify/fastify-autoload/pull/442 < I think fastify-autoload would need some fixing. I think we can access process.features to detect if there is the support instead of relying on the version number.

mcollina avatar Mar 08 '25 15:03 mcollina