justkey007 / tsc-alias

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

Incorrect resolveFullPaths #224

Open UchihaYuki opened 2 months ago

UchihaYuki commented 2 months ago

tsconfig.json

{
  "compilerOptions": {
    "target": "es2017", // Top-level 'await' expressions are only allowed when the 'target' option is set to 'es2017' or higher.
    "noImplicitAny": true,
    "module": "es2022", // Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve'
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "importHelpers": true,
    "sourceMap": true,
    "declaration": true,
    "moduleResolution": "Node10", // only support CommonJS require
    "baseUrl": "./",
    "paths": {
      "@uchihayuki/node-common": ["./dist"],
      "gulp": ["node_modules/gulp"]
    },
    "outDir": "./"
  },
  "include": ["gulpfile.ts", "gulp/**/*.ts", "src/**/*.ts", "test/**/*.ts"],
  "exclude": ["node_modules"],
  "tsc-alias": {
    "resolveFullPaths": true
  }
}

tsconfig.test.json

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "./test"
  },
  "include": ["test/**/*.ts"]
}

test/json.ts

import { expect } from "chai";
import { json } from "@uchihayuki/node-common";
import fs from "fs";
...

result after run npx tsc -p tsconfig.test.json && npx tsc-alias -p tsconfig.test.json

import { expect } from "chai";
import { json } from ".";
import fs from "fs";

Why @uchihayuki/node-common becomes .? Shouldn't it be ../dist/index.js?