Skip to content

Bug: third-party compiler, transpiler, swc backend should be resolved relative to tsconfig that declared it, not to the project #1662

Closed
@cspotcode

Description

@cspotcode

Bug: "compiler", "transpiler", and overridden swc backend resolve relative to the project, not to the tsconfig that declared them. This means an extended, reusable tsconfig that bundles its own dependencies cannot reliably declare these options.

compiler and transpiler

Both are module specifiers in a tsconfig file. We try to resolve them as if the tsconfig was an executable script that had done require.resolve().

overridden swc backend

I doubt anyone's using this config, since I don't think it's documented, but you can technically use our built-in swc transpiler, but with a non-standard @swc/core backend.

{
  // tsconfig.json
  "ts-node": {
    "transpiler": ["ts-node/transpilers/swc", {"swc": "third-party-swc-wrapper"}]
  }
}

This will attempt to require("third-party-swc-wrapper") instead of "@swc/core" or "@swc/wasm". You can also use this mechanism to force usage of "@swc/wasm" instead of "@swc/core", if your module graph has both on disk.

Same rules as above: we simulate if the tsconfig had been able to require.resolve() them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions