swc icon indicating copy to clipboard operation
swc copied to clipboard

--watch flag does not work under the same directory and documentation outdated

Open iwaduarte opened this issue 8 months ago • 1 comments

Describe the bug

There are two (2) problems related to the --watch flag that I want to report:

Outdated documentation

The documentation probably have outdated information.

swc seems to work fine without chokidar but the documentation states

Image

watch does not work in root folder (without /src nested folder level)

--watch does not work if the directory is under the same level as

backend/ ├── dist/ ├── controllers/ └── services/

So inside /backed something like "swc . -d dist -w" does not work. The build compiles and the application exits (does not stay actively listening to changes).

Input code


Config

{
  "$schema": "https://swc.rs/schema.json",
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": false,
      "decorators": false
    },
    "target": "es2020"
  },
  "module": {
    "type": "es6",
  }
}

Link to the code that reproduces this issue

https://play.swc.rs/?version=1.11.21&code=H4sIAAAAAAAAAzWKsQ2AMAwEeyR2eDEA2QQaFjDEKJaSOHLcIMTu0NCd7i6ELTGa6Z65QDq05gvGmZwjXOFfPrKAasSybr9yo9qbfJtoDYeWn9ESdZ7HQUpTc9wPTtOCKZLT9AI6np1%2BbwAAAA%3D%3D&config=H4sIAAAAAAAAA1WPSw7DIAwF9zkF8rrbdtE79BCIOhERP9mOVBTl7oUE0maH3xszsA5KwcwGnmotxzIkTYx0ziXhHER%2FSgKSE7IhmwRuvRWu1agd4x5tRwOiaUKpW8j3hoOLkbHjLfM22DH%2FC030iZD5ClZUh8nhVTc0Jfj4XvayfaQ%2B9tA%2F4Ad12XkxWH71TaEFh%2B0LYuVI0xQBAAA%3D

SWC Info output

Operating System:
    Platform: win32
    Arch: x64
    Machine Type: x86_64
    Version: Windows 11 Pro
    CPU: (16 cores)
        Models: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz

Binaries:
    Node: 22.14.0
    npm: N/A
    Yarn: N/A
    pnpm: N/A

Relevant Packages:
    @swc/core: 1.11.18
    @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

--watch should work for root files without being forced to work with src/ and /dist strategy --watch documentation should be updated to remove the use of chokidar

Actual behavior

No response

Version

1.11.18

Additional context

No response

iwaduarte avatar Apr 21 '25 00:04 iwaduarte

Note: The issue preventing file creation was not related to SWC (not a bug). It was caused by the IDE not automatically reflecting new files. I have updated accordingly.

iwaduarte avatar Apr 21 '25 15:04 iwaduarte