@architect/hydrate

中文文档
6.0.2发布于 2026/07/01Apache-2.0CommonJS构建来源已验证近 30 天下载 416.9万

Architect dependency hydrator and shared file manager

原始使用文档
文档目录3 节
  1. hydrate.install(options[, callback]) → [Promise]
  2. hydrate.update(options[, callback]) → [Promise]
  3. hydrate.shared(options[, callback]) → [Promise]

@architect/hydrate GitHub CI status

@architect/hydrate ensures that all functions managed by Architect have their dependencies installed. Functions containing all required dependencies are considered to be 'hydrated' - thus the name!

@architect/hydrate supports dependencies managed in the following languages using the following package managers:

  • Node.js via npm using package.json (and optionally package-lock.json), or via yarn using package.json and yarn.lock
  • Python via pip3 using a requirements.txt file
  • Ruby via bundle using Gemfile and Gemfile.lock files

Requirements

  • Node.js 22 or later is required to use @architect/hydrate version 6.0.0 and above
  • For Node.js 20 support, use @architect/hydrate version 5.x

Installation

npm install @architect/hydrate

API

All methods accept an options object can include the following properties:

  • autoinstall - Boolean - Enables or disables automated Lambda dependency treeshaking via static code analysis
    • Defaults to false
    • Used by install
  • basepath - String - Filesystem path in which Hydrate should search for functions
    • Defaults the current working directory
    • Useful if you want to hydrate one function or a subset of functions
    • Used by install + update
  • copyShared - Boolean - Enables or disables copying of shared code folders (e.g. src/shared) into Lambdas
    • Useful to disable if you want to just hydrate external dependencies
    • Defaults to true
    • Used by install + update
  • cwd - String - Root filesystem path of the project Hydrate is working in
    • Defaults to current working directory
    • May be the same or different from basepath; if using in conjunction with basepath, specify a subset of the project with basepath, for example:
      • { cwd: '/your/project/', basepath: '/your/project/src/http/' } runs Hydrate against /your/project/ (without having to use process.chdir) and only hydrates functions within /your/project/src/http/**
    • Used by install + update + shared
  • hydrateShared - Boolean - Enables or disables dependency hydration in shared code folders (e.g. src/shared)
    • Useful to disable if you want to just hydrate external dependencies
    • Defaults to true
    • Used by install + update
  • inventory - Object - Architect Inventory object; generally used internally
  • local - Boolean - Favor the local platform during installation of dependencies that may be distributed as platform-specific binaries
  • only - String - Specify a subset of possible shared files for shared to copy into Lambdas
    • Falsy by default
    • Accepts: shared, views, or staticJson
    • Used by shared
  • quiet - Boolean - Disables (most) logging
  • symlink - Boolean - Enables or disables symlinking instead of full directory copying, useful for local development
    • Defaults to false
    • Used by install + update + shared
  • timeout - Number - Amount of time in milliseconds to give each package manager process to execute
    • Used by install + update
  • verbose - Boolean - Enables verbose logging

Note on cwd vs basepath: cwd is necessary for Hydrate to find your project's manifest and key files and folders, while basepath scopes hydration to a specific path. When in doubt, include neither parameter, Hydrate will default to process working directory; if you know you need to aim Hydrate at a specific place but aren't sure which parameter to use, use cwd.

hydrate.install(options[, callback]) → [Promise]

Installs function dependencies, then invokes hydrate.shared().

To ensure local development behavior is as close to staging and production as possible, hydrate.install() (and other hydrate functions) uses:

  • Node.js: npm ci if package-lock.json is present and npm i if not; or yarn
  • Python: pip3 install
  • Ruby: bundle install

Note: by default update also installs dependencies in shared folders like src/shared and src/views.

hydrate.update(options[, callback]) → [Promise]

Updates function dependencies, then invokes hydrate.shared().

update is functionally almost identical to install, except it will update dependencies to newer versions if they exist. This is done via:

  • Node.js: npm update or yarn upgrade
  • Python: pip3 install -U --upgrade-strategy eager
  • Ruby: bundle update

Note: by default update also updates dependencies in shared folders like src/shared and src/views.

hydrate.shared(options[, callback]) → [Promise]

Copies shared code (from src/shared and src/views, or your custom @shared + @views paths, if any) into all functions.

版本与发布记录

@architect/hydrate 共发布 181 个版本,首次发布于 2019/05/31;过去 12 个月发布了 5 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
6.0.2latest2026/07/014 个月前
5.0.2v5-latest2026/03/048 个月前
5.0.2-RC.12026/03/048 个月前
6.0.02025/11/2811 个月前
5.0.2-RC.0RC2025/11/2511 个月前
5.0.12025/09/271.1 年前

其他发布通道:turbologger → 1.4.3-turbologger-1,RC → 5.0.2-RC.0,v5-latest → 5.0.2。

关于 @architect/hydrate 的常见问题

@architect/hydrate 是什么?

Architect dependency hydrator and shared file manager

如何安装 @architect/hydrate?

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

@architect/hydrate 支持 TypeScript 吗?

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

@architect/hydrate 支持 ESM 还是 CommonJS?

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

@architect/hydrate 需要什么版本的 Node.js?

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

@architect/hydrate 可以商用吗?

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

@architect/hydrate 的下载量有多少?

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

@architect/hydrate 还在维护吗?

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