Open
Description
Describe the bug
The --watch
mode in the SWC CLI does not detect newly added files within the watched directory. It only watches files that existed when the process started, which severely limits its usefulness for development workflows where new files are created.
Reproduction
- Run:
swc src -d dist --watch
-
Create a new .ts or .js file under src/
-
Observe: the new file is not compiled, and no rebuild is triggered
Input code
Config
{
"$schema": "https://swc.rs/schema.json",
"sourceMaps": true,
"minify": false,
"jsc": {
"parser": {
"syntax": "typescript",
"decorators": true,
"dynamicImport": true
},
"transform": {
"decoratorMetadata": true
},
"target": "es2023",
"baseUrl": "./"
},
"module": {
"type": "commonjs"
}
}
Link to the code that reproduces this issue
CLI issue
SWC Info output
Operating System:
Platform: darwin
Arch: x64
Machine Type: x86_64
Version: Darwin Kernel Version 24.5.0: Tue Apr 22 19:53:26 PDT 2025; root:xnu-11417.121.6~2/RELEASE_X86_64
CPU: (16 cores)
Models: Intel(R) Xeon(R) W-2140B CPU @ 3.20GHz
Binaries:
Node: 22.16.0
npm: 10.9.2
Yarn: 4.9.1
pnpm: N/A
Relevant Packages:
@swc/core: 1.11.29
@swc/helpers: N/A
@swc/types: 0.1.21
typescript: 5.8.3
SWC Config:
output: N/A
.swcrc path: N/A
Next.js info:
output: N/A
Expected behavior
New files added to the watched directory should trigger compilation, just like modified files.
Actual behavior
No response
Version
0.7.7
Additional context
No response