Skip to content

Commit

Permalink
Fix fsconfck loading behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
cometkim committed Jun 7, 2024
1 parent d32b8a3 commit 6f44020
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/tiny-berries-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nanobundle": patch
---

Fix fsconfck loading behavior
33 changes: 18 additions & 15 deletions packages/nanobundle/src/bin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/usr/bin/env node

import { parse as parseTsConfig } from 'tsconfck';
import {
parse as parseTsConfig,
TSConfckParseError,
type TSConfckParseResult,
} from 'tsconfck';
import dedent from 'string-dedent';

import { cli } from './cli';
Expand Down Expand Up @@ -32,20 +36,19 @@ try {
const manifest = await loadManifest({ basePath: flags.cwd });
reporter.debug('loaded manifest %o', manifest);

const tsconfigResult = await parseTsConfig(flags.tsconfig);
const tsconfigPath = (
tsconfigResult.tsconfigFile !== 'no_tsconfig_file_found'
? tsconfigResult.tsconfigFile
: undefined
);
let tsconfigResult: TSConfckParseResult | undefined;
try {
tsconfigResult = await parseTsConfig(flags.tsconfig);
} catch (err) {
if (err instanceof TSConfckParseError) {
throw err;
}
}
const tsconfigPath = tsconfigResult?.tsconfigFile;
if (tsconfigPath) {
reporter.debug(`loaded tsconfig from ${tsconfigPath}`);
}
const tsconfig = (
tsconfigResult.tsconfigFile !== 'no_tsconfig_file_found'
? tsconfigResult.tsconfig
: undefined
);
const tsconfig = tsconfigResult?.tsconfig;
if (tsconfig) {
reporter.debug('loaded tsconfig %o', tsconfig);
}
Expand Down Expand Up @@ -109,9 +112,9 @@ try {
}
} catch (error) {
if (error instanceof NanobundleError) {
if (error.message) {
reporter.error(error.message);
}
reporter.error(error.message);
} else if (error instanceof TSConfckParseError) {
reporter.error(error.message);
} else {
reporter.captureException(error);
}
Expand Down

0 comments on commit 6f44020

Please sign in to comment.