nonara / ts-patch

Augment the TypeScript compiler to support extended functionality
MIT License
764 stars 26 forks source link

[Feature Request] `--watch` for transformer changes #117

Open RedMser opened 1 year ago

RedMser commented 1 year ago

When using tspc --watch, I expect changes in transformers that are defined inside of my project (such as { transform: ./transformer.js } ) to be detected and TypeScript to re-compile the entire project. However, this does not happen.

theogravity commented 5 months ago

I have a use-case where I have a monorepo with several packages. Our tsconfig.json at the root as a bunch of these references, and we use the following command to watch and re-build:

tsc --build tsconfig.json --watch --preserveWatchOutput --verbose

Some of the references uses ts-patch with their own transformer plugins. In their own directories, running tsc directly (after ts-patch patch) works as it should.

But running that watch command from the root, I've tried tsc with the patch applied, and also tspc directly on the command, but it doesn't seem to execute those plugins.

I've also tried copying the plugin config over to the root and it doesn't seem to use the plugins as well.

ex: root tsconfig.json attempt (note: I added the plugins option here to just try to see if it would work; ideally it should just build with the plugins of that package)

{
  "compilerOptions": {
    "plugins": [
      {
        "transform": "typescript-file-copy-plugin",
        "after": true,
        "copy": [
          {
            "src": "./packages/utils/src/generated/*",
            "dest": "./packages/utils/dist/src/generated"
          }
        ]
      }
    ]
  },
  "files": [],
  "references": [,
    { "path": "./packages/utils" },
}

Edit: even tspc --build tsconfig.json doesn't activate the transformers from the root