@eppo/js-client-sdk-common

中文文档
5.0.0发布于 2026/05/06MITTypeScriptCommonJS近 30 天下载 65.1万

Common library for Eppo JavaScript SDKs (web, react native, and node)

原始使用文档
文档目录7 节
  1. Getting Started
  2. Local development
  3. Troubleshooting
  4. Installing local package
  5. Publishing Releases
  6. Tools
  7. Bootstrap Configuration

Common library for Eppo's JavaScript SDK

Test and lint SDK

Getting Started

Refer to our SDK documentation for how to install and use the SDK.

Local development

To set up the package for local development, run make prepare after cloning the repository

Troubleshooting

  • Jest encountered an unexpected token
Details:

/.../node_modules/@eppo/js-client-sdk-common/node_modules/uuid/dist/esm-browser/index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){export { default as v1 } from './v1.js';
                                                                                  ^^^^^^
SyntaxError: Unexpected token 'export'

Add the following line to your jest.config.js file: transformIgnorePatterns: ['<rootDir>/node_modules/(?!(@eppo|uuid)/)'],

Installing local package

It may be useful to install the local version of this package as you develop the client SDK or Node SDK. This can be done in two steps:

  1. Open the directory with the client SDK you want to add this library to, and run make prepare
  2. Add the local version of this library to the SDK you are developing by running yarn add --force file:../js-client-sdk-common (this assumes both repositories were cloned into the same directory)

Publishing Releases

When publishing releases, the following rules apply:

  • Standard Release:

    • Create a release with tag format vX.Y.Z (e.g., v4.3.5)
    • Keep "Set as latest release" checked
    • Package will be published to NPM with the latest tag
  • Pre-release:

    • Create a release with tag format vX.Y.Z-label.N (e.g., v4.3.5-alpha.1)
    • Check the "Set as pre-release" option
    • Package will be published to NPM with the pre-release label as its tag (e.g., alpha.1)

Note: The release will not be published if:

  • A pre-release is marked as "latest"
  • A pre-release label is used without checking "Set as pre-release"

Tools

Bootstrap Configuration

You can generate a bootstrap configuration string from either the command line or programmatically via the ConfigurationWireHelper class.

The tool allows you to specify the target SDK this configuration will be used on. It is important to correctly specify the intended SDK, as this determines whether the configuration is obfuscated (for client SDKs) or not (for server SDKs).

Command Line Usage

Install as a project dependency:

# Install as a dependency
npm install --save-dev @eppo/js-client-sdk-common

# or, with yarn
yarn add --dev @eppo/js-client-sdk-common

Common usage examples:

# Basic usage
yarn bootstrap-config --key <sdkKey> --output bootstrap-config.json

# With custom SDK name (default is 'js-client-sdk')
yarn bootstrap-config --key <sdkKey> --sdk android

# With custom base URL
yarn bootstrap-config --key <sdkKey> --base-url https://api.custom-domain.com

# Output configuration to stdout
yarn bootstrap-config --key <sdkKey> 

# Show help
yarn bootstrap-config --help

The tool accepts the following arguments:

  • --key, -k: SDK key (required, can also be set via EPPO_SDK_KEY environment variable)
  • --sdk: Target SDK name (default: 'js-client-sdk')
  • --base-url: Custom base URL for the API
  • --output, -o: Output file path (if not specified, outputs to console)
  • --help, -h: Show help

Programmatic Usage

import { ConfigurationHelper } from '@eppo/js-client-sdk-common';

async function getBootstrapConfig() {
  // Initialize the helper
  const helper = ConfigurationHelper.build(
    'your-sdk-key',
    {
      sdkName: 'android', // optional: target SDK name (default: 'js-client-sdk')
      baseUrl: 'https://api.custom-domain.com', // optional: custom base URL
    });

  // Fetch the configuration
  const config = await helper.fetchConfiguration();
  const configString = config.toString();

  // You are responsible to transport this string to the client
  const clientInitialData = {eppoConfig: eppoConfigString};

  // Client-side
  const client = getInstance();
  const initialConfig = configurationFromString(clientInitialData.eppoConfig);
  client.setInitialConfig(configurationFromString(configString));
}

The tool will output a JSON string containing the configuration wire format that can be used to bootstrap Eppo SDKs.

版本与发布记录

@eppo/js-client-sdk-common 共发布 107 个版本,首次发布于 2023/03/29;过去 12 个月发布了 3 个版本。

版本发布日期距今
5.0.0latest2026/05/066 个月前
4.15.52026/03/267 个月前
4.15.42026/03/177 个月前
4.15.32025/10/061.1 年前
4.15.22025/08/081.3 年前
4.15.12025/04/031.6 年前

其他发布通道:rc → 4.8.0-alpha.2,alpha.1 → 4.9.0-alpha.1,alpha → 4.8.3-alpha.5,alpha.0 → 4.12.1-alpha.0,alpha1 → 4.13.5-alpha1。

关于 @eppo/js-client-sdk-common 的常见问题

@eppo/js-client-sdk-common 是什么?

Common library for Eppo JavaScript SDKs (web, react native, and node)

如何安装 @eppo/js-client-sdk-common?

在项目目录运行 npm install @eppo/js-client-sdk-common,或使用 pnpm add / yarn add / bun add。

@eppo/js-client-sdk-common 支持 TypeScript 吗?

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

@eppo/js-client-sdk-common 支持 ESM 还是 CommonJS?

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

@eppo/js-client-sdk-common 需要什么版本的 Node.js?

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

@eppo/js-client-sdk-common 可以商用吗?

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

@eppo/js-client-sdk-common 的下载量有多少?

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

@eppo/js-client-sdk-common 还在维护吗?

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