@commerce-klaus/sfcc-module-resolver

中文文档
2.2.0发布于 2026/10/30MITTypeScriptESM + CJS构建来源已验证近 30 天下载 2607

Shared SFCC cartridge path and module resolution utilities

原始使用文档
文档目录4 节
  1. Highlights
  2. Install
  3. Documentation
  4. License

NPM version Downloads

@commerce-klaus/sfcc-module-resolver

Shared Node.js utilities for SFCC cartridge order, module resolution, super modules, and hook registrations. Most projects use it indirectly through the Commerce Klaus ESLint, TypeScript, Vite, or Babel packages.

Highlights

  • Infers cartridge order from configuration, environment, jsconfig, or site.xml
  • Explains which cartridge-order source won, including missing entries and invalid fallbacks
  • Resolves */, ~/, cartridge aliases, and module.superModule
  • Explains resolution with every attempted file path and the selected match
  • Provides deterministic filesystem helpers for SFCC-aware tooling
  • Normalizes Custom Attribute and preference definitions from site metadata
  • Reads and resolves cartridge hook registrations
  • Discovers effective hook scripts in cartridge-path order
  • Reads job step definitions, parameters, status codes, execution capabilities, and task timeouts from steptypes.json
  • Validates hook, job step, and Custom API contracts with structured diagnostics
  • Builds deterministic project graphs for cartridge precedence, super modules, SFRA controller routes, effective middleware pipelines, and metadata contracts

ModuleResolutionOptions is the shared configuration type used by the Vite and Vitest adapters. ResolveCartridgeRootsOptions extends it with the resolver-only containingFile option.

Projects can put shared options in commerce-klaus.config.ts or commerce-klaus.config.js. Package options remain supported and override the central values. The public configuration contract lives in @commerce-klaus/config; see the project configuration guide.

Install

pnpm add @commerce-klaus/sfcc-module-resolver
npm install @commerce-klaus/sfcc-module-resolver
yarn add @commerce-klaus/sfcc-module-resolver
vp install @commerce-klaus/sfcc-module-resolver
import {
  createModuleResolver,
  explainCartridgeOrder,
  inferCartridgeOrder,
} from "@commerce-klaus/sfcc-module-resolver/resolution"

const cartridgeRoots = inferCartridgeOrder({ cartridgesDir: "cartridges" })
const resolveSfccModule = createModuleResolver(cartridgeRoots)
const orderTrace = explainCartridgeOrder({ cartridgesDir: "cartridges" })

The package provides focused entry points for resolution, object-metadata, hooks, job-steps, custom-apis, and project-wide validation and graphs under project. The package root contains the resolution API only.

Documentation

See the complete API and resolution reference.

License

MIT

版本与发布记录

@commerce-klaus/sfcc-module-resolver 共发布 17 个版本,首次发布于 2026/07/10;过去 12 个月发布了 17 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.2.0latest2026/10/3011 天前
2.1.12026/10/2813 天前
2.1.02026/10/2417 天前
2.0.02026/10/051 个月前
1.9.12026/10/011 个月前
1.9.02026/09/281 个月前

关于 @commerce-klaus/sfcc-module-resolver 的常见问题

@commerce-klaus/sfcc-module-resolver 是什么?

Shared SFCC cartridge path and module resolution utilities

如何安装 @commerce-klaus/sfcc-module-resolver?

在项目目录运行 npm install @commerce-klaus/sfcc-module-resolver,或使用 pnpm add / yarn add / bun add。

@commerce-klaus/sfcc-module-resolver 支持 TypeScript 吗?

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

@commerce-klaus/sfcc-module-resolver 支持 ESM 还是 CommonJS?

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

@commerce-klaus/sfcc-module-resolver 可以商用吗?

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

@commerce-klaus/sfcc-module-resolver 的下载量有多少?

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

@commerce-klaus/sfcc-module-resolver 还在维护吗?

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