@abaplint/transpiler-cli

中文文档
2.14.18发布于 2026/11/06MITTypeScript零依赖近 30 天下载 3.8万

Transpiler - Command Line Interface

原始使用文档
文档目录4 节
  1. Examples
  2. Output layout
  3. Pinning a library
  4. Duplicate dependencies

@abaplint/transpiler-cli

Transpiler CLI

Examples

Call abap_transpile on the command line, see example in

https://github.com/larshp/abap-advent-2020/blob/main/package.json#L8

Shared factory functions for repeated composite type constructors are enabled by default. Each factory call creates a fresh ABAP value. To preserve inline constructor output, set options.sharedTypeFactories to false in abap_transpile.json:

{
  "options": {
    "sharedTypeFactories": false
  }
}

Omit the option or set it to true to use shared factories.

Output layout

The CLI writes generated project files into output_folder/project/. All input_folder entries belong to the same project, including an array of source folders. Original ABAP sources stay in their input directories.

Each ABAP library gets its own folder under output_folder. The folder name is the repository basename from url (without a trailing slash or .git), or the basename of folder for a local-only library. Set libs[].name to override it:

{
  "input_folder": ["src", "extra"],
  "output_folder": "output",
  "incremental_output": true,
  "libs": [
    {"url": "https://github.com/open-abap/open-abap-core"},
    {"folder": "./deps/utilities", "name": "utilities"}
  ],
  "write_unit_tests": true,
  "write_source_map": true,
  "options": {"addCommonJS": true}
}
output/
  init.mjs
  _init.mjs
  _top.mjs
  index.mjs
  _unit_open.mjs
  project/
    zapp.prog.mjs
    zapp.prog.mjs.map
  open-abap-core/
    ...
  utilities/
    ...

Names must be valid single directory names on Windows and POSIX. Names are unique without regard to case, and project is reserved. A conflicting derived name needs an explicit libs[].name. Duplicate ABAP objects across libraries are rejected by default; a project object replaces a library object of the same type/name.

Class locals, test classes, function groups, MIME data, and source maps follow their owning object. Source maps include ABAP source content, including libraries loaded from temporary Git checkouts; they use stable library-qualified paths and do not expose the temporary checkout location. Imports and registered MIME filenames reference the new paths.

Shared initialization scripts and test runners remain at the output root. Run programs with node output/project/zapp.prog.mjs; run project unit tests with node output/index.mjs. When migrating from flat output, rebuild a clean generated output directory and update scripts that reference individual modules or assets.

Set incremental_output to true to skip writing unchanged files, replace changed generated files, and remove obsolete files recorded in output/.abap-transpile-manifest.json. The CLI preserves files it did not generate, including custom setup scripts and other user data. Existing output from runs before this option was enabled has no ownership inventory; do one clean build when adopting the option to remove legacy stale files. Set the option to false (the default) to restore unconditional writes. Files generated while it is disabled are not added to the inventory.

The manifest is updated atomically and retained as a recovery aid if a run fails. This does not make the entire output tree transactional. Use one transpiler process per output directory.

The transpiler library retains flat output unless its caller supplies an output folder map as the third argument to Transpiler.run(). This layout is enabled automatically by the CLI.

Pinning a library

A library given by url is cloned when the CLI runs, so without more the default branch of that moment is used and the same project commit can build differently from one day to the next. Set libs[].ref to a commit SHA, a tag or a branch to make the build reproducible:

{
  "libs": [
    {"url": "https://github.com/open-abap/open-abap-core", "ref": "239b817e6fd05e62854fed25663f002c60dda07c"},
    {"url": "https://github.com/example/utilities", "ref": "v1.2.0"}
  ]
}

A branch or tag is cloned shallow. A commit is fetched shallow by name; when the server does not serve that, or the SHA is abbreviated, the full history is fetched and the commit checked out from it. The CLI prints the commit of every library it clones, and of every folder library that is a git checkout, as commit: <sha> next to the file count, so the commits of a build can be recorded.

Duplicate dependencies

By default, two libraries defining the same ABAP object (type and name) cause an Ambiguous dependency object error. To keep existing dependency repositories and skip later copies, set this top-level option in abap_transpile.json:

{
  "skip_duplicate_dependencies": true
}

The first library in libs containing an object wins. Every file of that object in later libraries is skipped, including metadata, class locals, and binary assets. The CLI warns once per skipped object per library, naming the selected library. Imports, output folders, and source maps use the selected copy. Project objects still take precedence over dependencies, and shared package.devc.xml metadata keeps its existing behavior.

Library order now affects generated output. Different definitions can change DDIC types, available methods, and runtime behavior, or cause syntax errors in code expecting the skipped version. This option does not check that copies are equivalent or suppress syntax checking. Put the intended provider first and run your application's tests. For selective control, use libs[].exclude_filter to exclude only the unwanted object's files instead. With incremental_output enabled, changing providers removes obsolete files tracked in the manifest. Use a clean generated output directory when changing providers in legacy mode or when untracked stale output remains from earlier builds.

版本与发布记录

@abaplint/transpiler-cli 共发布 1,429 个版本,首次发布于 2020/09/26;过去 12 个月发布了 146 个版本。

版本发布日期距今
2.14.18latest2026/11/06今天
2.14.172026/11/051 天前
2.14.162026/11/042 天前
2.14.152026/10/298 天前
2.14.142026/10/288 天前
2.14.132026/10/289 天前

关于 @abaplint/transpiler-cli 的常见问题

@abaplint/transpiler-cli 是什么?

Transpiler - Command Line Interface

如何安装 @abaplint/transpiler-cli?

在项目目录运行 npm install @abaplint/transpiler-cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 abap_transpile,可以用 npx abap_transpile 直接运行。

@abaplint/transpiler-cli 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@abaplint/transpiler-cli 可以商用吗?

@abaplint/transpiler-cli 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@abaplint/transpiler-cli 的下载量有多少?

根据 npm 官方下载统计,@abaplint/transpiler-cli 在 2026/10/05 – 2026/11/03 这 30 天内被下载 38,024 次,日均约 1,267 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@abaplint/transpiler-cli 还在维护吗?

最新版本 2.14.18 发布于 2026/11/06(今天);至今共发布 1429 个版本,其中过去 12 个月发布了 146 个;首次发布于 2020/09/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。