37 GB
4,042,753 files
Updated about 1 month ago
Name
Size
src
tests
CHANGELOG.md2.38 kB
xet
README.md3.57 kB
xet
deno.json399 Bytes
xet
mod.ts652 Bytes
xet
README.md

@zuke/tsc-alias

Typed tsc-alias task wrappers for Zuke builds, in a fluent settings-lambda API. tsc-alias rewrites the TypeScript path aliases declared in your tsconfig.json paths mapping into plain relative imports in the compiled output, so the JavaScript emitted by tsc runs without a path resolver. Arguments stay a discrete argv array, so command construction is injection-free.

import { TscAliasTasks } from "@zuke/tsc-alias";

await TscAliasTasks.run((s) => s.project("tsconfig.json").resolveFullPaths());

Run it after tsc (or alongside it with .watch()) to fix up the alias imports in the freshly compiled files.

Paths

Every path argument accepts either a string or an AbsolutePath from @zuke/core, so a path built with absolutePath can be passed in directly.

API

Full typed API — generated from deno doc
`@zuke/tsc-alias` — typed `tsc-alias` task wrappers for Zuke builds.

`tsc-alias` rewrites TypeScript path aliases (the `paths` mapping in
`tsconfig.json`) into relative imports in the compiled output, so the emitted
JavaScript runs without a path resolver. Configure a fluent settings object in
a lambda; the task builds the argv and runs it.

```ts
import { TscAliasTasks } from "@zuke/tsc-alias";
await TscAliasTasks.run((s) => s.project("tsconfig.json").resolveFullPaths());
```
@module

const TscAliasTasks: TscAliasTasksApi
  Typed task functions for the `tsc-alias` path-alias rewriter.

class TscAliasRunSettings extends ToolSettings
  Settings for a `tsc-alias` run.

  override protected defaultTool(): string
    The executable this settings object drives (`tsc-alias`).
  override protected defaultResolution(): ToolResolution
    Resolve the binary from `node_modules/.bin` by default — tsc-alias is an npm-distributed tool.
  project(path: PathLike): this
    Path to the `tsconfig.json` to read aliases from (`-p`/`--project`).
  watch(): this
    Re-run on file changes (`--watch`).
  outDir(path: PathLike): this
    Output directory of the compiled files to rewrite (`--outDir`).
  declarationDir(path: PathLike): this
    Output directory of the emitted declaration files (`--declarationDir`).
  resolveFullPaths(): this
    Attempt to fully resolve alias paths, including extensions (`--resolveFullPaths`).
  resolveFullExtension(ext: string): this
    Extension to append when resolving full paths, e.g. `.js` (`--resolveFullExtension`).
  replacers(...files: PathLike[]): this
    Additional replacer module file(s); repeatable (`-f`/`--replacers`).
  dir(path: PathLike): this
    Base directory to resolve relative paths against (`--dir`).
  fileExtensions(list: string): this
    Comma-separated list of file extensions to process (`--fileExtensions`).
  verbose(): this
    Print verbose output (`--verbose`).
  debug(): this
    Print debug output (`--debug`).
  silent(): this
    Suppress all output (`--silent`).
  override protected onOutput(output: CommandOutput): void
    Report `Files` rewritten (under `--verbose`) onto the build summary.
  override protected buildArgs(): string[]
    Assemble the `tsc-alias` argv from the configured settings.

interface TscAliasTasksApi
  The shape of {@link TscAliasTasks}.

  run(configure?: Configure<TscAliasRunSettings>): Promise<CommandOutput>
    Rewrite TypeScript path aliases in compiled output with `tsc-alias`.
Total size
37 GB
Files
4,042,753
Last updated
Oct 24
Pre-warmed CDN
US EU US EU

Contributors