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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@eliyya/typed-css-modules

v1.0.2

Published

Creates .d.ts files from CSS Modules .css files with a nextjs pluggin

Readme

withTypeCSSModule

A Next.js plugin that wraps the typed-css-modules library, enabling automatic generation of .d.ts files for CSS Modules in TypeScript projects. This plugin integrates seamlessly with your Next.js project and simplifies the usage of typed-css-modules by:

  1. Running it automatically for all CSS Module files in your project.
  2. Watching for changes in your CSS Module files and regenerating the .d.ts files when necessary.
  3. Exporting all the functionalities of typed-css-modules so you can use it directly if the plugin is not required.

Features

  • Automatic Type Generation: No need to run typed-css-modules manually.
  • File Watching: Watches your CSS Module files and regenerates .d.ts files on change.
  • Customizable Extensions: Supports .module.css, .module.scss, and other extensions.
  • Debounce Support: Prevents excessive executions during rapid file changes.
  • Direct Access to typed-css-modules: Exposes the original API for advanced use cases.

Installation

Install the package using npm or yarn:

npm install typed-css-modules

Include the plugin in your next.config.mjs file:

import { withTypeCSSModule } from '@eliya/typed-css-modules'

const nextjsConfig = {
    // your nextjs config
}

export default withTypeCSSModule(nextjsConfig)

Usage

Plugin Mode

By default, the plugin automatically generates .d.ts files for all CSS Module files in your Next.js project.

Example next.config.mjs:

import { withTypeCSSModule } from '@eliya/typed-css-modules'

const nextjsConfig = {
    // your nextjs config
}

export default withTypeCSSModule(nextjsConfig, {
    extensions: ['.module.css', '.module.scss'], // optona;
    debounceWait: 300, // optona;
})
  • extensions: Specifies the file extensions to watch and process. Default: ['.module.css'].
  • debounceWait: Time in milliseconds to wait before regenerating types after a file change. Default: 200.

Direct API Usage

If you prefer to use typed-css-modules directly, the plugin exports all its functionalities. For example:

import { run } from '@eliya/typed-css-modules'

run('./src', {
    silent: true,
    pattern: '**/*.module.css',
})

This works the same way as calling run from the typed-css-modules package itself.


Example Project Structure

project-root/
├── src/
│   ├── components/
│   │   ├── Button.module.css
│   │   └── Button.module.css.d.ts <-- generated
│   └── pages/
├── next.config.mjs
└── package.json

How It Works

  1. Initial Run: When you include the plugin, it automatically generates .d.ts files for all CSS Modules matching the specified extensions.
  2. File Watching: Uses fs.watch to monitor changes in the src directory and regenerates .d.ts files for modified CSS Module files.
  3. Debounced Updates: Uses a debounce mechanism to reduce redundant type generation during rapid file modifications.

Notes

  • Ensure your CSS Modules follow the naming convention (e.g., *.module.css).
  • If using custom extensions like .module.scss, you need to configure the extensions option.
  • The plugin does not interfere with other Next.js configurations.

License

This plugin is licensed under the MIT License.