justkey007 / tsc-alias

Replace alias paths with relative paths after typescript compilation
MIT License
896 stars 62 forks source link

What am I doing wrong? 0 files processed. #112

Closed thetayloredman closed 2 years ago

thetayloredman commented 2 years ago

tsconfig:

    "tsc-alias": {
        "verbose": true,
        "resolveFullPaths": true
    }

script:

        "build": "tsc && tsc-alias",

used tsc-alias and it works:

[logn@logn ProtoBot]$ tsc && tsc-alias
tsc-alias info: 9 files were affected!

used build script and it fails

[logn@logn ProtoBot]$ npm run build

> protobot@2.1.0 build
> tsc && tsc-alias

tsc-alias info: 0 files were affected!

via npx also affects 0:

[logn@logn ProtoBot]$ npx tsc-alias
tsc-alias info: 0 files were affected!

Environment issue? my fault?

raouldeheer commented 2 years ago

@thetayloredman can you provide us the console output when running with -r debugger.js? Working version and nonworking version? debugger.js file placed next to tsconfig.json. With the debugger.js file contents being:

const util = require('util');
let loggedConfig = true;
exports.default = ({ orig, file, config }) => {
    if (loggedConfig) {
        console.log(util.inspect(config, {showHidden: false, depth: null, colors: true}));
        loggedConfig = false;
    }
    console.log(orig);
    console.log(file);
    return orig;
};
thetayloredman commented 2 years ago

@raouldeheer

[logn@logn ProtoBot]$ npx tsc-alias -r debugger.js
tsc-alias error: Failed to import replacer "debugger.js"
tsc-alias info: 0 files were affected!
[logn@logn ProtoBot]$ tsc-alias -r ./debugger.js 
tsc-alias error: Failed to import replacer "./debugger.js"
tsc-alias info: 0 files were affected!
thetayloredman commented 2 years ago

same without ./

raouldeheer commented 2 years ago

Can you give us a file tree of your project directory? For example using the tree command

thetayloredman commented 2 years ago
$ tree -I 'node_modules' -I 'logs' -I 'data'
.
├── clean.sh
├── CODE_OF_CONDUCT.md
├── commitlint.config.js
├── CONTRIBUTING.md
├── debugger.js
├── ecosystem.config.js
├── install.sh
├── LICENCE
├── package.json
├── package-lock.json
├── README.md
├── src
│   ├── commands
│   │   ├── admin.ts
│   │   ├── boop.ts
│   │   ├── cat.ts
│   │   ├── cuties.ts
│   │   ├── dog.ts
│   │   ├── fox.ts
│   │   ├── fursona.ts
│   │   ├── help.ts
│   │   ├── hug.ts
│   │   ├── info.ts
│   │   ├── koala.ts
│   │   ├── meme.ts
│   │   ├── owos.ts
│   │   ├── pat.ts
│   │   ├── source.ts
│   │   ├── tildes.ts
│   │   ├── uwuify.ts
│   │   └── uwus.ts
│   ├── config.rename-me.ts
│   ├── config.ts
│   ├── header.ts
│   ├── hooks
│   │   ├── owos.ts
│   │   ├── tildes.ts
│   │   └── uwus.ts
│   ├── index.ts
│   ├── lib
│   │   ├── Client.ts
│   │   ├── CommandHandler.ts
│   │   ├── EnmapVerbose.ts
│   │   ├── interfaces
│   │   │   ├── commands
│   │   │   │   ├── CommandCategory.ts
│   │   │   │   ├── CommandConfig.ts
│   │   │   │   └── Command.ts
│   │   │   ├── Config.ts
│   │   │   ├── db
│   │   │   │   ├── Cooldowns.ts
│   │   │   │   ├── Fursona.ts
│   │   │   │   ├── UserConfig.ts
│   │   │   │   └── UserStats.ts
│   │   │   ├── Hook.ts
│   │   │   ├── Logger.ts
│   │   │   └── PublicConfig.ts
│   │   ├── memstat.ts
│   │   ├── onready
│   │   │   ├── index.ts
│   │   │   ├── init.ts
│   │   │   ├── loadhooks.ts
│   │   │   ├── restart.ts
│   │   │   └── status.ts
│   │   ├── types
│   │   │   └── Augments.d.ts
│   │   └── utils
│   │       └── doesHavePrefix.ts
│   ├── log.ts
│   └── publicConfig.ts
├── start.sh
├── templatecmd.ts
├── templateHook.ts
├── tsconfig.eslint.json
└── tsconfig.json

11 directories, 66 files

repo (before esm migration; that's not pushed)

raouldeheer commented 2 years ago

@thetayloredman In the tsconfig.json the outDir is set to "./dist/". Try using "./dist"?

thetayloredman commented 2 years ago

@raouldeheer That fixed it... oversight in tsc-alias?

raouldeheer commented 2 years ago

Yes this bug will be fixed in the next patch

wight554 commented 2 years ago

Yes this bug will be fixed in the next patch

I've tried applying patch locally, but it doesn't really help when outDir has subfolder it worked fine before though in my case path is: "outDir": "dist/server" I've tried:

    "outDir": "./dist/server",
    "outDir": "./dist/server/",
    "outDir": "dist/server/",

None worked

wight554 commented 2 years ago

still broken on MacOS:

  System:
    OS: macOS 12.3.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 4.16 GB / 32.00 GB
    Shell: 5.8 - /bin/zsh

Debugger gist: https://gist.github.com/wight554/98dbf3e7d713366824ec28a58240fd98

raouldeheer commented 2 years ago

@wight554 the problem is that the @server alias resolves to dist/server/server because the outDir is dist/server. But dist/server/server doesn't exist so the aliases aren't resolved.

These are the files tsc-alias found:

dist/
  server/
    getViteServer.js
    server.js
    app/
      AppModule.js
    auth/
      AuthController.js
      AuthService.js
      AuthModule.js
      guards/
        JwtAuthGuard.js
        LocalAuthGuard.js
      strategies/
        JwtStrategy.js
        LocalStrategy.js
    comment/
      CommentController.js
      CommentModule.js
      CommentService.js
      dto/
        CreateCommentDto.js
        UpdateCommentDto.js
      schemas/
        CommentSchema.js
    crypto/
      CryptoModule.js
      CryptoService.js
    decorators/
      UserDecorator.js
    interceptors/
      MongooseClassSerializerInterceptor.js
    post/
      PostController.js
      PostModule.js
      PostService.js
      dto/
        CreatePostDto.js
        UpdatePostDto.js
      schemas/
        PostSchema.js
    user/
      UserController.js
      UserModule.js
      UserService.js
      dto/
        CreateUserDto.js
        UpdateUserDto.js
      schemas/
        UserSchema.js
    utils/
      prettyPrintAddress.js
wight554 commented 2 years ago

@wight554 the problem is that the @server alias resolves to dist/server/server because the outDir is dist/server. But dist/server/server doesn't exist so the aliases aren't resolved.

These are the files tsc-alias found:

dist/
  server/
    getViteServer.js
    server.js
    app/
      AppModule.js
    auth/
      AuthController.js
      AuthService.js
      AuthModule.js
      guards/
        JwtAuthGuard.js
        LocalAuthGuard.js
      strategies/
        JwtStrategy.js
        LocalStrategy.js
    comment/
      CommentController.js
      CommentModule.js
      CommentService.js
      dto/
        CreateCommentDto.js
        UpdateCommentDto.js
      schemas/
        CommentSchema.js
    crypto/
      CryptoModule.js
      CryptoService.js
    decorators/
      UserDecorator.js
    interceptors/
      MongooseClassSerializerInterceptor.js
    post/
      PostController.js
      PostModule.js
      PostService.js
      dto/
        CreatePostDto.js
        UpdatePostDto.js
      schemas/
        PostSchema.js
    user/
      UserController.js
      UserModule.js
      UserService.js
      dto/
        CreateUserDto.js
        UpdateUserDto.js
      schemas/
        UserSchema.js
    utils/
      prettyPrintAddress.js

The project structure is src/ server/ test/ With alias @src @server @test I build only server folder with tsc, so I set include: ['server'] and build to dist/server I use server alias in server folder If I set outDir to ./dist, it'll build server folder containts to ./dist and will look for nested server folder like this: ./server/utils/ while it should look like this: ./utils It worked fine before 1.6.5 Project is here: https://github.com/wight554/blog-template

raouldeheer commented 2 years ago

@wight554 Changing the build:server script from tsc-alias -p tsconfig.server.json to tsc-alias --dir dist fixes the issue.

SafeShows commented 1 year ago

I was having the same issue with tsc-alias info: 0 files were affected! but when I added --dir dist to tsc-alias it fixed it 👍🏼