LeDDGroup / typescript-transform-paths

Transforms module resolution paths using TypeScript path mapping and/or custom paths
MIT License
480 stars 27 forks source link

[Bug] Paths are not rewritten on incremental compilation with --watch flag #177

Open aplex opened 1 year ago

aplex commented 1 year ago

When I run the tsc --build, or "tsc --watch" compiles for the first time, everything works fine and import paths are rewritten correctly.

However, if I change a file in tsc watch mode, it is recompiled and import pa paths are left as is, without being converted to relative.

I'm using tspc with persistent patch mode.

versions:

npx tsc --version
Version 5.1.3

"typescript-transform-paths": "^3.4.6",
"tspc": "^1.1.2",

tsconfig:

{
  "compilerOptions": {
    "module": "Node16",
    "moduleResolution": "Node16",
    "composite": true,
    "preserveSymlinks": true,
    "declaration": true,
    "declarationMap": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "useDefineForClassFields": true,
    "target": "ES2021",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./src",
    "incremental": true,
    "skipLibCheck": true,

    "lib": [
      "es2015.reflect",
      "dom",
      "ES6",
      "ES2021.String"
    ],
    "jsx": "react",

    "paths": {
      "@/*": ["./*"]
    },
    "plugins": [
      // Transform paths in output .js files
      { "transform": "typescript-transform-paths" },
      // Transform paths in output .d.ts files (Include this line if you output declarations files)
      { "transform": "typescript-transform-paths", "afterDeclarations": true }
    ]
  },
  "references": [
    {
      "path": "../common"
    }
  ],
}
ivanpopelyshev commented 6 months ago

This is problem for me as well. @nonara any ideas where to start digging to patch this?

I use tsc --watch to evade rollup or other bundlers, to spam F5 faster :) after update to recent version of typescript (5.4.x) watch is broken :(

ivanpopelyshev commented 6 months ago

Somehow it helps when I use import * as myLib from 'myLib' , that way watch works fine in most cases.

ivanpopelyshev commented 6 months ago

Ha-ha, there was typescript service "run on recompile" enabled in my intellij idea. That was the cause