Skip to content

Accept an explicit tsconfig path through the API, not only TS_NODE_PROJECT / OXC_TSCONFIG_PATH #806

Description

@fengmk2

An explicit tsconfig can only be selected through environment variables: init_resolver reads TS_NODE_PROJECT, then OXC_TSCONFIG_PATH (src/lib.rs#L1515-L1516).

That is awkward for a tool that wraps the loader and lets its user pick a tsconfig. Vite+ runs scripts with vpx --tsconfig <path> script.ts:

  • Setting OXC_TSCONFIG_PATH for the loader also sets it for the user's script and for every process the script spawns. A nested oxnode, or another loader, then inherits a tsconfig chosen for the outer script.
  • A TS_NODE_PROJECT that the user exported for ts-node takes precedence over OXC_TSCONFIG_PATH, so the wrapper would have to remove it from the environment, which changes what the user's own child processes see.

Proposal

Accept the path through the API, so a loader can pass it without touching process.env. For example:

  • an option on the OxcTransformer constructor and on createResolve/load (e.g. { tsconfig?: string }); or
  • a function such as setTsconfigPath(path) that must run before the first transform or resolve, since the resolver and tsconfig source live in a process-wide OnceLock.

The environment variables would keep working as they do now.

Today Vite+ patches the variable name to its own VP_SCRIPT_TSCONFIG.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions