LeDDGroup / typescript-transform-paths

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

[Bug] Edge cases in ts-node #162

Closed carlocorradini closed 1 year ago

carlocorradini commented 1 year ago

Maintainers Note

ts-node was updated with new internal logic. Formerly, ts-node would pass no Program instance when it was executed with the transpileOnly option.

Recent logic has changed to where it passes a stripped Program, which was causing several issues. I attempted to fix this in (3.4.0), but there were some edge cases that were not covered, as evidenced by the following bug report.

We have corrected the logic to better accommodate these changes and ts-node in both transpileOnly and typeCheck modes.


Bug Report

Context

Project available at https://github.com/carlocorradini/reCluster/tree/main/server

tsconfig.json

Available at https://github.com/carlocorradini/reCluster/blob/main/server/tsconfig.json Content:

{
  "compilerOptions": {
    // ...
    "paths": {
      "~*": ["./src/*"]
    },
    // ...
    "plugins": [
      {
        "transform": "typescript-transform-paths"
      },
      {
        "transform": "typescript-transform-paths",
        "afterDeclarations": true
      }
    ]
  },
}

Problem

ts-patch has been correctly applied. In development I use ts-node-dev and start the server with the following npm script:

npx ts-node-dev --respawn --clear --rs --transpile-only --require tsconfig-paths/register src/main.ts

It worked flawlessly until I've updated typescript-transform-paths to v3.4.0:

Error: Cannot find module '...'
Require stack: ...

What is the possible cause of this? Thanks! 🥳😥

nonara commented 1 year ago

Thanks for the report! This should be fixed in v3.4.2. Let me know if you still face any issues.

Issue Details

ts-node was updated with new internal logic. Formerly, ts-node would pass no Program instance when it was executed with the transpileOnly option.

Recent logic has changed to where it passes a stripped Program, which was causing several issues. I attempted to fix this in (3.4.0), but there were some edge cases that were not covered, as evidenced by the following bug report.

We have corrected the logic to better accommodate these changes and ts-node in both transpileOnly and typeCheck modes.

carlocorradini commented 1 year ago

Awesome! It's working now. Thanks! 🥳