Wildcard to include all subfolders when compiling using esbuild

Viewed 17

When I am using esbuild I find I have to list all of the sub folders in order to get them to compile.

For example:

esbuild server/*.ts server/**/*.ts server/**/**/*.ts --bundle --platform=node --outdir=dist

I am building a fastify app with the @fastify/autoload plugin so not all of my files are imported and hence, can not all be located via imports from the main entry point.

How can I tell esbuild to look in every subfolder in server and compile all of the .ts files it finds?

1 Answers

I did not need esbuild to achieve this task. Esbuild is a bundler, all I was looking to do was compile my Typescript code into Javascript.

I was able to achieve this by using the ts-node package. I replaced my script with the below and it has resolved my issues.

ts-node ./server/server.ts

I have, however, noticed that ts-node is noticeably slower than esbuild. Hopefully it will become faster over time.

Related