fastify-cli
fastify-cli copied to clipboard
add experimental-strip-types in app-ts-esm
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
- [x] run
npm run testandnpm run benchmark - [ ] tests and/or benchmarks are included
- [ ] documentation is changed or added
- [x] commit message and code follows the Developer's Certification of Origin and the Code of conduct
Once strip types ships in Node v20, I'd recommend shipping a new version of this as a semver-major.
Why is FASTIFY_AUTOLOAD_TYPESCRIPT=1 needed?
Why is
FASTIFY_AUTOLOAD_TYPESCRIPT=1needed?
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
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.