-
-
Notifications
You must be signed in to change notification settings - Fork 65
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
Add support for .ts files when app is not run with ts-node. #264
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add some tests with vitest, so we make sure we do not regress in vitest support?
Yes, will work on adding some tests with vitest. Good idea. |
@mcollina all set. added some tests with vitest. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
This change is breaking my non-ts fastify servers #266 |
It also not work with vite-node either with vite-plugin-node
|
Please open your own issue with a proper reproducible example. |
This branch adds support for
.ts
files when the application is not run withts-node.
The specific use case for this is mentioned in #230. Vitest does not run withts-node
(it useses-build
) to compile TypeScript. This creates a situation where some.ts
files that AutoLoad tries to import fails because there is no Typescript transpiler.This pull request resolves #230.
To make the tests fail
Replace lines 32-42 in
test/commonjs/error.js
withapp3.register(require('./index-error/app'))
. This will cause the plugin to loadts-node
from the Node modules and not throw an error to the user that they need to installts-node
.Replace
index.js
with the current version of the file in themaster
branch. This will cause the test files intest/commonjs/ts-node.js
to error because it cannot load.ts
files without either being run with ts-node or the ts-noderegister
that is added in this branch.Notes
I did not modify any documentation as the error messages in
index.js
will still make sense. Happy to revise the documentation if requested.Per request, I added
vite
andvitest
as devDependencies and added some vitest tests so that we don't lose vitest support.Also happy to make any changes needed to this. Thanks for reviewing!
Checklist
npm run test
andnpm run benchmark