Skip to content

Custom TypeScript config filename #617

Description

@prastoin

Introduction

Hello there ! first of all thanks for the great work, using preconstruct was very smooth and helped me a lot to understand multi-entrypoint import both in esm/cjs

Related PR #618

The issue

Right now unless I'm mistaken, will only be computed the package/tsconfig.json.
This could be a bottleneck when working with composite TypeScript projects ( aka solution style TypeScript configuration ) or when having a dedicated tsconfig json file for build etc.

// tsconfig.json
{
   // ...
  "files": [],
  "include": [],
  "references": [
    {
      "path": "./tsconfig.lib.json"
    },
    {
      "path": "./tsconfig.spec.json"
    }
  ]
}

Actual

In this way, from my understanding of the preconstruct the current "stick to tsconfig.json" behavior is implied by the

// cli/src/rollup-plugins/typescript-declarations/common.ts

export async function getProgram(dirname: string, pkgName: string, ts: TS) {
  let configFileName = ts.findConfigFile(dirname, ts.sys.fileExists);

Which has this signature

  function findConfigFile(searchPath, fileExists, configName = "tsconfig.json") {

Suggestion

Adding a new configuration option tsConfigFilename under a typescript configuration object in Preconstruct's config:

{
  "preconstruct": {
    "typescript": {
      "tsConfigFilename": "tsconfig.build.json"
    }
  }
}

Related pull-request

Created this #618 in order to give more context and consistency to this issue
Tests might not be the most idiomatic and such could also be the configuration naming 😅 let me know !

As always any suggestions are welcomed !
Have a great day !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions