-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
How can I use esbuild to replace tsc when developing backend code #1519
Comments
You didn’t find it in the docs because esbuild doesn’t do this. It’s a bundler, not a tsc replacement. It’s probably possible to use esbuild to build someone like a tsc replacement but it’s not built in. |
You can use estrella - https://github.com/rsms/estrella, which uses esbuild and provides the functionality you require. Or build your own FS listener that run esbuild on changed files outputting them to dist and re-running your process. |
To people who found this issue: I don't know why I had some previous memory that |
That is not true for large codebases. swc is another interesting option. |
Added a build script to run the TypeScript compiler, rather than running it myself. Looking into some other setups to help automate the library setup a bit more. Looking into adding a `rm -rf ./dist` (`npx rimraf ./dist`) call before `npx tsc`, since sometimes some ghost files are there after removing old files that are no longer in the codebase (they are still in `./dist` though). But, thinking about it, I also don't want to accidentally remove files that are meant to be there, so I probably won't add it. I will have to remember to reset the `./dist` folder myself, if I removed a file from `./src`. https://stackoverflow.com/questions/45082648/npm-package-json-os-specific-script https://github.com/isaacs/rimraf While looking into that, I also found an article about making your npm package into a shell script. I realized that could be a great thing for NBTify to have too! Hadn't even thought about that before. Being able to simply install NBTify globally to your machine, then running it as a command, `nbtify`, and it can manipulate NBT files directly on your file system. Then you wouldn't even need to write a JavaScript script to work with NBTify! I'm gonna go make an issue over on GitHub for that! A really cool thing to look into next. #25 https://blog.deepgram.com/npx-script/ https://2ality.com/2022/07/nodejs-esm-shell-scripts.html#node.js-esm-modules-as-standalone-shell-scripts-on-unix https://github.com/nodejs/modules/issues/152 Not too familiar with all of the different ways to add scripts to your npm package, so I'm looking to find out what most libraries do, since it doesn't always seem to be the same thing (`npm run dev` vs `npm start`). https://docs.npmjs.com/cli/v9/using-npm/scripts https://stackoverflow.com/questions/69400243/whats-the-difference-between-npm-run-dev-and-npm-run-start-in-next-js https://stackoverflow.com/questions/51358235/difference-between-npm-start-and-npm-run-start Relating to the previous thing, it sounds like some TypeScript libraries will run their dev server using `tsc` for the type checking, then instead use `esbuild` for the build process, since it tends to be much quicker, and it doesn't perform any type checking. I think it's because you don't need to worry about type errors during the build process, but instead during the dev process, when you're actively working on the project. I do like that crossover to make things a bit lighter to build for production. evanw/esbuild#1519
For AWS Lambda deployment, we tried to make the cold start faster and esbuild made it possible for us. It's true that you don't need this most of the time but not for lambda. We only use it for some of our critical lambda like custom API Gateway Lambda Authorizer. |
I want to use esbuild for transpiling not for speed in first case, but to be sure that generated code will be same - esbuild and tsc output may differ sometimes. Also i can't use bundling, because some modules are importing dynamically . |
This is probably a stupid question, and probably not the intended use of esbuild, but I have a very simple goal:
src
, which includes many .ts files and sub folders.src
intodist
, turning all .ts files into .js, but retaining folder structures and filenames, without any bundling.dist
folder.This is exactly what tsc does, but I want to use esbuild instead of tsc for speed. I might run
tsc --noEmit
once before deploy, but that's all.Since this goal is very common and very simple, I wonder what the "standard recommendation" is to achieve it. I didn't find it in the docs. Thanks!
The text was updated successfully, but these errors were encountered: