justkey007 / tsc-alias

Replace alias paths with relative paths after typescript compilation
MIT License
876 stars 63 forks source link

Path starting with @ is not replaced #212

Open razor-x opened 6 months ago

razor-x commented 6 months ago

Reproducible in this project https://github.com/seamapi/types at this commit: https://github.com/seamapi/types/commit/68ec4828c2c835d1a0694185d6dcd01fa2fe0a5b

Project defines paths as

{
    "paths": {
      "@seamapi/types": ["./src/index.ts"],
      "@seamapi/types/connect": ["./src/connect.ts"],
      "@seamapi/types/devicedb": ["./src/devicedb.ts"],
      "lib/*": ["./src/lib/*"]
    }
}

And has an import statement

import { schemas as devicedb_schemas } from '@seamapi/types/devicedb'

but in the final output, this import statement is unchanged, however it should be replaced as

import { schemas as devicedb_schemas } from '../../../../../../devicedb.js';

Workaround is adding a custom replacer: https://github.com/seamapi/types/pull/610