Skip to content
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

In composite projects with ttypescript, ts-node should call transformers with parameters defined on the tsconfig.json of the executed file instead of the original one #1945

Open
aquilae opened this issue Jan 27, 2023 · 0 comments

Comments

@aquilae
Copy link

aquilae commented Jan 27, 2023

Search Terms

composite, transform, ttypescript

Expected Behavior

When building a composite project, typescript/ttypescript picks up the transformers defined on each nested project.
For example, with this structure:

root/
 - tsconfig.json with transform A
 - root.ts
 - app/
  - tsconfig.json with transform B
  - app.ts

transform A will be applied to root.ts and transform B will be applied to app.ts.

In repro branch:

> npx ttsc -b
another transform subapp.ts with ../visitor
transform root.ts with ./visitor

Actual Behavior

ts-node currently reads transformers once from the tsconfig.json corresponding to the file you pass as an argument, and then applies the same transformer to all the files it encounters even when importing files under a different composite project.

root/
 - tsconfig.json with transform A
 - root.ts
 - app/
  - tsconfig.json with transform B
  - app.ts

Running ts-node root.ts, transform A will be applied both to root.ts and app.ts

In repro branch:

> npx ts-node -C ttypescript root.ts
transform root.ts with ./visitor
transform subapp.ts with ./visitor

In practice, that completely breaks not only the ability to use different transformers for different projects, but also the support for relative path parameters to transformers.

Steps to reproduce the problem

Set up a composite TS project with different transformers for root and nested projects, notice the difference in transformer calls between ttsc -b and ts-node -C ttypescript ..

Minimal reproduction

Repro repo PR: TypeStrong/ts-node-repros#32

> npx ttsc -b
another transform subapp.ts with ../visitor
transform root.ts with ./visitor

> npx ts-node -C ttypescript root.ts
transform root.ts with ./visitor
transform subapp.ts with ./visitor

Specifications

  • ts-node version: v10.9.1
  • node version: v16.17.1
  • TypeScript version: v4.9.4
  • tsconfig.json, if you're using one:
{
  "compilerOptions": {
    "outDir": ".typescript",
    "plugins": [
      {
        "type": "program",
        "transform": "./transform.js",
        "visitor": "./visitor"
      }
    ]
  },
  "references": [
    { "path": "./subapp" }
  ],
  "files": ["root.ts"]
}

  • package.json:
{
  "version": "0.0.1",
  "devDependencies": {
    "ts-node": "^10.9.1",
    "ttypescript": "^1.5.15",
    "typescript": "^4.9.4"
  }
}

  • Operating system and version: Win 10
  • If Windows, are you using WSL or WSL2?: No
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