@guardian/commercial-core

中文文档
35.1.2发布于 2026/10/13Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 1.6万

Guardian advertising business logic

原始使用文档
文档目录4 节
  1. Installation
  2. Development
  3. Testing
  4. Releasing to NPM

@guardian/commercial-core

This directory contains the modules that are published as the @guardian/commercial-core npm package.

Installation

To install the npm package, install with your favourite package manager:

pnpm i @guardian/commercial-core
yarn add @guardian/commercial-core
npm i @guardian/commercial-core

Development

build the package with:

pnpm build

This will build the package into the dist directory, which is what is published to npm.

Testing

To run the unit tests:

pnpm test

This might fail if the base test coverage hasn't been met. This is set in jest.config.js. Ensure you add sufficient tests to meet the threshold if you can. If this is not possible for whatever reason, you can decrease the set thresholds but this should be considered a last resort

Beta Releases

You can add the [beta] @guardian/commercial-core label to your pull request, this will release a beta version of the bundle to NPM, the exact version will be commented on your PR.

In order to do this, run pnpm changeset. This will create a new changeset file in the .changeset directory. Commit this file with your PR.

Note: Once the beta version is released, the label will be removed from the PR, so you will need to add it again if you want to release subsequent new versions.

Releasing to NPM

This repository uses changesets for version management.

To release a new version with your changes, run:

pnpm changeset add

and follow the prompts. This will create a new changeset file in the .changeset directory. Commit this file with your PR.

When your PR is merged, changeset will analyse the changes and create a PR to release the new version.

if you are part of the commercial team, you can merge the changeset PR to release the new version. If you are not part of the commercial team, you will need to ask someone who is to merge the PR for you.

版本与发布记录

@guardian/commercial-core 共发布 172 个版本,首次发布于 2020/09/11;过去 12 个月发布了 32 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
35.1.2latest2026/10/131 个月前
35.1.12026/10/091 个月前
35.1.02026/09/082 个月前
35.0.02026/09/082 个月前
0.0.0-beta-20260819145422beta2026/08/192 个月前
0.0.0-beta-202608191448552026/08/192 个月前

关于 @guardian/commercial-core 的常见问题

@guardian/commercial-core 是什么?

Guardian advertising business logic

如何安装 @guardian/commercial-core?

在项目目录运行 npm install @guardian/commercial-core,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@guardian/libs(^33.0.0)、@guardian/consent-manager(^2.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@guardian/commercial-core 支持 TypeScript 吗?

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

@guardian/commercial-core 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@guardian/commercial-core 可以商用吗?

@guardian/commercial-core 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@guardian/commercial-core 的下载量有多少?

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

@guardian/commercial-core 还在维护吗?

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