Skip to content

About transpiled require path #1611

Open
@ChouUn

Description

@ChouUn

Structure:

- project/
    - src/
    - tsconfig.json
- wc3-mono/
    - pkgs/
        - wc3-base/
            - src/
                - Game.ts
            - package.json
        - wc3-types/
    - package.json

The package manager is Yarn 2 with PnP, and I have executed yarn link.
so package.json be like:

{
  "devDependencies": {
    "wc3-base": "workspace:^",
  },
  "resolutions": {
    "wc3-base": "portal:../wc3-mono/pkgs/wc3-base",
  }
}

To be able to use import { Game } from 'wc3-base/Game', I should write tsconfig.json as:

{
  "compilerOptions": {
    "baseUrl": "./src",
    "paths": {
      "wc3-base/*": ["../../wc3-mono/pkgs/wc3-base/src/*"]
    },
  },
}

This has made me a little uncomfortable.
Perhaps there is a more elegant solution.

And the import statement will be transpiled as require("wc3-mono.pkgs.wc3-base.src.Game") finally.
It makes me very upset. I expected that I would get a require("wc3-base.Game")

I spent a lot of time reading the source code of TSTL so that I could write a plugin to change the situation.
But I didn't succeed, so I'm looking for some help on where to start.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions