Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
aplex opened this issue Jun 25, 2023 · 3 comments
Open

Comments

@aplex
Copy link

aplex commented Jun 25, 2023

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
Copy link

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
Copy link

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

@ivanpopelyshev
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants