I loved nodemon + ts-node, for CommonJS.
But unfortunately it is VERY DIFFICULT to set them up with ES Module.
So I did the same but with esbuild.
This package is designed to quickly solve the developper struggling issues related to ES Modules with typescript and nodejs, both build and watch/restart.
Prerequisites:
You should already have a npm project using typescript, want to compile it with ESM (EcmaScript Modules), have set type=module in package.json.
npm i -D @jlguenego/esbuild-watch-restart
To start a build like nodemon
npx ewr src/server.ts
For build only:
npx ewr --build-only src/server.ts
Of course this is better to create scripts in package.json:
"scripts": {
"start": "ewr src/server.ts",
"build": "ewr --build-only src/server.ts",
"start:prod": "node dist/server.js",
"clean": "rimraf dist",
"lint": "eslint ."
},KISS : Keep It Stupidely Simple
No configuration except:
--build-onlyoption.
Feel free to ask more options but you know it is better to not have a lot.
The repo has an examples project. Go in it to check its content.
I intend to maintain regularely this project. So feel free to make issue for making it better for your needs.
I develop for users, not for the beauty of code.
git clone https://github.com/jlguenego/esbuild-watch-restart.git
To publish
cd lib
npm run release
Jean-Louis GUENEGO [email protected]