Skip to content

transpiler / swc things to double-check #1613

@cspotcode

Description

@cspotcode

Capturing a few items from my personal to-do list that need to be double-checked:

  • when swc: true, make sure path is an absolute path to ts-node's own SWC transpiler

    • absolute path to the swc transpiler, which itself is responsible for finding and loading @swc/core or @swc/wasm
  • Within swc transpiler

    • use tsconfig-relative require() to find swc first
    • fallback to require() relative to ts-node, in case ts-node is a global installation
  • When transpiler is a string, do project-local require

  • When transpiler is the ts-node/transpilers/swc-experimental, also fallback to absolute path to globally-installed-ts-node-transpiler for backwards compat

    • can we do this with require.resolve(specifier, {paths})?
  • Consider genericizing this require() logic

    • We have several use-cases for this: locate transpiler, locate compiler, locate @swc/core|wasm, locate --require
    • make a single require.resolve wrapper that understands the nuance of how we locate dependencies in all the above situations
      - if specifier comes from a tsconfig, attempt to resolve relative to tsconfig
      - if specifier comes from API or CLI, attempt to resolve relative to ...
      - CWD?
      - entrypoint? (for shebangs?) No, the shebang case is handled by having a tsconfig next to the entrypoint
  • tweak swc jsdoc to link to ts-node website, since it requires installing additional deps

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