Skip to content

About transpiled require path #1611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ChouUn opened this issue Jan 15, 2025 · 0 comments
Open

About transpiled require path #1611

ChouUn opened this issue Jan 15, 2025 · 0 comments

Comments

@ChouUn
Copy link

ChouUn commented Jan 15, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant