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

@zslabs/atomic-css-modules

v0.2.1

Published

Extract repeated CSS Modules declarations into shared atomic classes

Readme

@zslabs/atomic-css-modules

Extracts repeated CSS Modules declarations into shared atomic classes via composes.

Requirements

  • Node.js >=20.17 or >=22.5 (uses path.matchesGlob)
  • CSS Modules source (.module.css)
  • Vite ^8 when using the Vite plugin (vite is an optional peer)

The core processCssModules API has no Vite dependency.

Install

npm install @zslabs/atomic-css-modules
import { defineConfig } from 'vite'
import { atomicCssModules } from '@zslabs/atomic-css-modules/vite'

export default defineConfig({
  plugins: [
    atomicCssModules({
      include: ['src/**/*.module.css'],
    }),
  ],
})

| Option | Default | Notes | | ------------ | --------------------------------- | --------------------------------------------------- | | include | **/*.module.css | Globs relative to the Vite root | | exclude | **/node_modules/** | | | debugNames | true in serve, false in build | Readable atoms (color-red-a1b2c3) vs short hashes | | report | "summary" | "verbose" lists each skipped selector | | preprocess | — | (code, filePath) => code before scan/atomize |

How it works

Matching declarations share one registry class. Single local classes are eligible, including simple pseudos and nested at-rules.

.card {
  color: red;
  &:hover {
    color: blue;
  }
  @media (min-width: 600px) {
    padding: 16px;
  }
}

becomes:

/* module */
.card {
  composes: bn89ziv jtnf3j g1h5a7 from global;
}
/* registry */
.bn89ziv {
  color: red;
}

.jtnf3j:hover {
  color: #00f;
}

@media (width >= 600px) {
  .g1h5a7 {
    padding: 16px;
  }
}

Selector eligibility, shorthand/longhand rules, and non-goals: GUIDE.md.

Skipping

Add /* atomic: skip */ before a selector, or as the first comment in a rule block, to leave that rule alone. Use it when a declaration would atomize but sharing it would break cascade or you need the styles to stay on the local class.

buildStart logs atom count, skip reasons, and source vs registry bytes.

Caveats

  • Only selectors that CSS Modules can composes are atomized (see the guide).
  • Shorthand + longhand in the same rule skip those properties for that rule.
  • Stick to CSS Modules local classes. Do not stack atomized classes, or another utility system on the same node, to override the same property. Prefer one class, or /* atomic: skip */ when sharing would be wrong.
  • On small sheets, gzip/brotli often erase the atomic class win (many one-declaration rules compress worse than fewer larger ones). The payoff shows up when UI grows against a shared token surface: Modules CSS scales with components, the atom set scales with the design system.
  • This is 0.x: the supported surface below is stable within a minor when practical, but breaking changes may land before 1.0.

Public API

Supported

  • @zslabs/atomic-css-modules/vite — atomicCssModules, plugin option types, registry virtual module ids
  • @zslabs/atomic-css-modules — processCssModules, ProcessOptions / ProcessResult and related result types, SKIP_REASONS / report helpers used with the pipeline

Internal (exported for advanced use and tests; may change without a major bump)

  • FileScanCache, scanFiles, rewriteFiles, buildRegistryCss, sortAtomsForRegistry, comparePropertyCascadeOrder, ensureUniqueAtomNames, syncScanAtomHashes, and lower-level atom/scan types
import { processCssModules } from '@zslabs/atomic-css-modules'

const result = processCssModules([{ filePath: 'button.module.css', code }], {
  registryImportPath: './atomic-registry.css',
  composeFrom: 'file', // Vite plugin uses 'global'
  sourceMap: true,
})

License

MIT