From 58d0145e846def5a7a21a71ede8f58c2b72af92d Mon Sep 17 00:00:00 2001 From: Julien Goux Date: Fri, 10 Jun 2022 17:08:43 +0200 Subject: [PATCH] feat(cli): add `--tsconfig` flag to accept custom tsconfig path (#652) * feat: expose tsconfig option * write a test * oops, remove the only function * no need for a snapshot Co-authored-by: EGOIST --- src/cli-main.ts | 1 + test/index.test.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/cli-main.ts b/src/cli-main.ts index 21944395..0ae381b7 100644 --- a/src/cli-main.ts +++ b/src/cli-main.ts @@ -79,6 +79,7 @@ export async function main(options: Options = {}) { default: 'node', }) .option('--loader ', 'Specify the loader for a file extension') + .option('--tsconfig ', 'Use a custom tsconfig') .option('--config ', 'Use a custom config file') .option('--no-config', 'Disable config file') .option('--shims', 'Enable cjs and esm shims') diff --git a/test/index.test.ts b/test/index.test.ts index e30ae854..9e426547 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -439,6 +439,21 @@ test('onSuccess', async () => { expect(logs.includes("world")).toEqual(true) }) +test('custom tsconfig', async () => { + await run( + getTestName(), + { + 'input.ts': `export const foo = 'foo'`, + 'tsconfig.build.json': `{ + "compilerOptions": { + "baseUrl":"." + } + }`, + }, + { flags: ['--tsconfig', 'tsconfig.build.json'] } + ) +}) + test('support baseUrl and paths in tsconfig.json', async () => { const { getFileContent } = await run(getTestName(), { 'input.ts': `export * from '@/foo'`,