dividab / tsconfig-paths

Load node modules according to tsconfig paths, in run-time or via API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When used with ts-node, tsconfig-paths should use the same tsconfig.json as ts-node when autodiscovering

rhyek opened this issue · comments

Hello. Not sure what project would need to support this, so I am linking to the issue in ts-node: TypeStrong/ts-node#1948

FYI my current workaround:

#!/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',
    },
  );
})();