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

When used with tsconfig-paths, tsconfig-paths should use a ts-node provided tsconfig.json path #1948

Open
rhyek opened this issue Feb 1, 2023 · 1 comment

Comments

@rhyek
Copy link

rhyek commented Feb 1, 2023

Desired Behavior

ts-node can resolve a tsconfig.json file relative to the entrypoint script. This is great. It seems tsconfig-paths will instead try to use the current working directory. This means that when combining both, different tsconfig paths will be resolved if you are relying on auto-discovery and the entrypoint script is not located in the cwd.

Is this request related to a problem?

When using tsconfig-paths, I have to either provide the project param explicitly or only use entrypoint scripts in my cwd.

@rhyek
Copy link
Author

rhyek commented Feb 1, 2023

My current workaround is a wrapper for both libraries:

my-ts-node.ts

#!/usr/bin/env ts-node --transpileOnly
import execa from 'execa';
import * as ts from 'typescript';

const entrypoint = process.argv[2];
const configFile = ts.findConfigFile(entrypoint, ts.sys.fileExists);

const args = process.argv.slice(3);

void (async () => {
  await execa(
    '/usr/bin/env',
    [
      'ts-node',
      ...(configFile
        ? ['--project', configFile, '--require', 'tsconfig-paths/register']
        : []),
      entrypoint,
      ...args,
    ],
    {
      stdio: 'inherit',
    },
  );
})();

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