@embroider/addon

中文文档
0.30.0发布于 2020/11/04MIT近 30 天下载 4132

The default blueprint for ember-cli addons.

原始使用文档
文档目录6 节
  1. Compatibility
  2. Installation
  3. The Utilities
  4. ensureSafeComponent
  5. Contributing
  6. License

@embroider/addon

Utilities to help addons with Embroider support.

Compatibility

  • Ember.js v3.13 or above
  • Ember CLI v2.13 or above
  • Node.js v10 or above

Installation

ember install @embroider/addon

The Utilities

ensureSafeComponent

This function aids you in eliminating un-analyzable usage of the {{component}} helper. For the full explanation of why and how you would do this, see the Addon Author Guide.

Example usage in Javascript:

import { ensureSafeComponent } from '@embroider/addon';
import Component from '@glimmer/component';
import DefaultTitleComponent from './default-title';

export default class extends Component {
  get title() {
    return ensureSafeComponent(this.args.title || DefaultTitleComponent, this);
  }
}
<this.title />

Example usage in a template:

{{#let (ensure-safe-component (or @title (component "default-title"))) as |Title|}}
  <Title />
{{/let}}

The first argument is allowed to be:

  • a string. If we see a string, we will emit a deprecation warning because passing components-as-strings doesn't work safely under Embroider with staticComponents enabled. We will return a value that is safe to invoke (via angle brackets) on your current Ember version.
  • a curried component definition (which is the kind of value you receive when someone does <YourComponent @customThing={{component "fancy"}}/>). These are returned unchanged, because they're always safe to invoke.
  • a component class, in which case if your ember version does not yet support directly invoking component classes, we will convert it to a curried component definition for you.

In the Javascript version, you must pass a second argument that is any object with an owner (a Component instance works great).

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

版本与发布记录

@embroider/addon 共发布 3 个版本,首次发布于 2020/10/22;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.30.0latest2020/11/046 年前
0.29.02020/10/286 年前
0.28.02020/10/226 年前

关于 @embroider/addon 的常见问题

@embroider/addon 是什么?

The default blueprint for ember-cli addons.

如何安装 @embroider/addon?

在项目目录运行 npm install @embroider/addon,或使用 pnpm add / yarn add / bun add。

@embroider/addon 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/embroider__addon 是否存在。

@embroider/addon 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js 10.* || >= 12。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@embroider/addon 可以商用吗?

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

@embroider/addon 的下载量有多少?

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

@embroider/addon 还在维护吗?

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