Skip to content

Commit

Permalink
feat: add option to be silent with no tsconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
haikyuu committed Jan 28, 2023
1 parent d6d2b73 commit 31d5a53
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ export default (opts: PluginOptions = {}): Plugin => {
let projectRoot = config.root
let workspaceRoot!: string

let { root } = opts
let { root, silent } = opts
const tsconfckOptions = {
resolveWithEmptyIfConfigNotFound: silent
}

if (root) {
root = resolve(projectRoot, root)
} else {
Expand Down Expand Up @@ -80,14 +84,17 @@ export default (opts: PluginOptions = {}): Plugin => {
await Promise.all(
projects.map((tsconfigFile) =>
hasTypeScriptDep
? tsconfck.parseNative(tsconfigFile)
: tsconfck.parse(tsconfigFile)
? tsconfck.parseNative(tsconfigFile, tsconfckOptions)
: tsconfck.parse(tsconfigFile, tsconfckOptions)
)
)
)

resolversByDir = {}
parsedProjects.forEach((project) => {
if(project.tsconfigFile === "no_tsconfig_file_found"){
return
}
// Don't create a resolver for projects with a references array.
// Instead, create a resolver for each project in that array.
if (project.referenced) {
Expand Down
6 changes: 6 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ export interface PluginOptions {
* necessary.
*/
parseNative?: boolean
/**
* Enable use of `tsconfck.resolveWithEmptyIfConfigNotFound`.
* If set to false (the default), the plugin will throw an error if no tsconfig file is found.
* @default false
*/
silent?: boolean
}

export interface TSConfig {
Expand Down

0 comments on commit 31d5a53

Please sign in to comment.