npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vite-plugin-sfcc-modules

v1.0.0

Published

Vite plugin to handle non-standard module paths used by Salesforce Commerce Cloud (SFCC)

Readme

vite-plugin-sfcc-modules

CI npm License: MIT

A Vite plugin that resolves Salesforce Commerce Cloud (SFCC) server-side module patterns.

This package originates from babel-plugin-sfcc-modules and is the port to a modern Vite ecosystem. The goal is the same DX for SFCC module resolution, but natively in Vite/Vitest without a Babel runtime layer.

TL;DR

import sfccModules from "vite-plugin-sfcc-modules"

export default defineConfig({
  plugins: [
    sfccModules({
      cartridgePath: ["app_brand", "app_core", "app_storefront_base"],
      basePath: "./cartridges",
    }),
  ],
})
// resolves first match in cartridge path
const foo = require("*/cartridge/scripts/foo")

// resolves inside the caller's own cartridge
const bar = require("~/cartridge/scripts/bar")

// resolves to next cartridge in path — rewritten to a static import
const base = module.superModule

Why this plugin exists

SFCC projects often use module patterns that are not standard Node.js resolution:

  • require("*/cartridge/scripts/foo")
  • require("~/cartridge/scripts/bar")
  • module.superModule

This plugin resolves those patterns according to cartridge path order and rewrites source code so Vite can process the full module graph.

Features

  • Resolves require("*/...") against the configured cartridge path in order.
  • Resolves require("~/...") against the caller's own cartridge.
  • Resolves module.superModule to the next cartridge implementation.
  • Supports .js, .ds, and .json file extensions.
  • Works in Vite and Vitest pipelines.

Installation

pnpm add -D vite-plugin-sfcc-modules

or

npm i -D vite-plugin-sfcc-modules

or

yarn add -D vite-plugin-sfcc-modules

Usage

Add the plugin to your Vite config:

import { defineConfig } from "vite"
import sfccModules from "vite-plugin-sfcc-modules"

export default defineConfig({
  plugins: [
    sfccModules({
      cartridgePath: ["app_brand", "app_core", "app_storefront_base"],
      basePath: "./cartridges",
    }),
  ],
})

Options

| Option | Type | Required | Description | | --------------- | ---------- | -------- | -------------------------------------------------------------------------------------------------- | | cartridgePath | string[] | yes | Ordered cartridge lookup path. First match wins. | | basePath | string | yes | Path to the folder containing cartridges in cartridgePath. Resolved relative to process.cwd(). |

Resolution behavior

1. require("*/...")

Searches all cartridges in cartridgePath order and picks the first matching file.

2. require("~/...")

Resolves only in the current file's cartridge.

3. module.superModule

Resolves to the next matching module in cartridge path order after the current cartridge.

Important: module.superModule is rewritten to a static import, not a runtime require(). This is intentional so Vite can transform transitive super-module chains as part of the normal module graph.

Vite + Vitest notes

  • Use the plugin in the top-level plugins array of vite.config.ts.
  • Do not rely on test-only plugin wiring that skips transitive transforms.
  • In tests, prefer static import over createRequire, since createRequire bypasses Vite transforms.

Relationship to babel-plugin-sfcc-modules

| Topic | babel-plugin-sfcc-modules | vite-plugin-sfcc-modules | | -------------------- | ------------------------------ | --------------------------------- | | Transformation layer | Babel | Vite transform pipeline | | Runtime setup | Often Babel tooling / register | Native Vite/Vitest | | Main use case | Babel-based SFCC toolchains | Modern Vite-based SFCC toolchains |

Development

This repository uses Vite+ (vp):

vp install
vp check
vp test
vp run build

License

MIT