@diez/compiler-core

中文文档
10.6.0发布于 2020/05/21SEE LICENSE.mdTypeScriptCommonJS近 30 天下载 9905

The Diez compiler and related functionality.

原始使用文档

@diez/compiler-core

This package provides base classes which can be used to build compilers from Diez projects into any target language, framework, or platform. A dependency on @diez/compiler-core registers the CLI command diez compile --target <target-name>, which compiles a Diez project for a given compiler target (e.g. android, ios, or web) into the build directory.

Compilation is typically executed in two phases.

Phase 1: Parsing

The compiler core itself has very few requirements; it can be executed against any TypeScript project with this approximate shape:

project-root
├── package.json
├── src
│   └── index.ts
└── tsconfig.json

Running yarn create diez sets up a project with this structure for you.

At compile time, the diez compile command first parses the TypeScript AST of every component exported from src/index.ts, then recursively parses its component properties. For example, given these contents:

import {Color} from '@diez/prefabs';

class Palette {
  red = Color.rgb(255, 0, 0);
}

export class DesignLanguage {
  palette = new Palette();
}

the parser will build a typed, abstract tree based on the exported component DesignLanguage. Because Color and Palette are recursive dependencies of DesignLanguage, they will also be processed. The resulting abstract tree is the main input to the next compilation phase.

Phase 2: Compilation

The compilation phase generates native source code for the requested target platform. This process typically involves generating design token component classes from code templates, assembling additional functionality and features from native bindings, transcribing file assets and other dependencies, and ultimately writing build artifacts out to disk.

For convenience, the compiler core includes an abstract compiler class. Although this class may provide useful time-saving abstractions, there is no requirement to use it when building support for a new Diez compiler target.

版本与发布记录

@diez/compiler-core 共发布 30 个版本,首次发布于 2019/09/25;过去 12 个月发布了 0 个版本。

版本发布日期距今
10.6.0latest2020/05/216 年前
10.6.0-beta.12020/05/216 年前
10.6.0-beta.02020/05/206 年前
10.5.22020/04/236 年前
10.5.02020/04/046 年前
10.5.0-beta.62020/04/046 年前

其他发布通道:10.2.0-beta.0 → 10.2.0-beta.0,10.2.0-beta.1 → 10.2.0-beta.1,10.2.0-beta.2 → 10.2.0-beta.2,10.3.0-beta.0 → 10.3.0-beta.0,10.4.0-beta.0 → 10.4.0-beta.0,10.4.0-beta.1 → 10.4.0-beta.1。

关于 @diez/compiler-core 的常见问题

@diez/compiler-core 是什么?

The Diez compiler and related functionality.

如何安装 @diez/compiler-core?

在项目目录运行 npm install @diez/compiler-core,或使用 pnpm add / yarn add / bun add。

@diez/compiler-core 支持 TypeScript 吗?

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

@diez/compiler-core 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@diez/compiler-core 可以商用吗?

@diez/compiler-core 使用 SEE LICENSE.md 许可。声明的许可为 SEE LICENSE.md,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@diez/compiler-core 的下载量有多少?

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

@diez/compiler-core 还在维护吗?

最新版本 10.6.0 发布于 2020/05/21(6 年前);至今共发布 30 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/09/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。