Replies: 5 comments 3 replies
-
Seems like a good idea to me. But I'm not sure how other cli tools work. I'm currently planning a rewrite of cli, and I'll add an option for it if it still seems good after looking at other projects. |
Beta Was this translation helpful? Give feedback.
-
Has this been implemented yet? Or do we still have to use nodemon to do this? |
Beta Was this translation helpful? Give feedback.
-
Hey @kdy1! If you're looking for other CLI tools, there's tsup (which uses esbuild under the hood) and they have a similar approach, they provide the I would love to see this feature because I want to watch, build, and reload, this flag would be super useful and easy because for now, we need I can even help with code if necessary. |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
Hello, I don't see this option in swc, however I'd use the following: #LINUX only
yarn swc -d dist **/*.ts src/**/* -w --copy-files & node --watch dist/src # Windows Portable
yarn add -D concurrently
yarn concurrently 'swc -d dist src/**/* -w --copy-files' 'node --watch dist/src' Please note that It's not the same as a success watch build callback, but it still works (kinda well), it's what we Brazilians call "gambiarra", aka workaround Also node got an experimental ts compiling feature, but really I wouldn't use that, as it needs to be set up correctly to work with enums and other stuff The only drawback of the concurrent approach is that node might start before the build finished (race condition), which would make it trigger rebuild later, I'm not sure if it would trigger multiple rebuilds for each changed file or only one rebuild If you like the answer, please give me a follow :) |
Beta Was this translation helpful? Give feedback.
-
It would be useful if
swc
could run a command after a successful transpile when--watch
mode is enabled.Something like this to re-run Node with the new files:
swc ./src -d ./dist --watch --onSuccess "node dist/index.js"
Similar to how
tsc-watch
has--onSuccess
:tsc-watch --onSuccess "node dist/index.js"
For now, I'm using a combination of
swc
andchokidar
:swc
watches for changes in./src
and transpiles them to./dist
. Thenchokidar
runsnode
on the updated./dist/index.js
.It works but I expect it's not very efficient to watch both the src and dist folders for changes when
swc
already knows what files have changed. Does anyone have a better solution?In case anyone else needs something similar, here's what the
package.json
scripts look like:Beta Was this translation helpful? Give feedback.
All reactions