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 🙏

© 2024 – Pkg Stats / Ryan Hefner

esbuild-plugin-lightningcss-modules

v0.1.2

Published

Yet another (minimal) css modules plugin using parcels rust based lightningcss implementation. (Full support for `composes: mixin from "./mixin.module.css"`)

Downloads

2,908

Readme

esbuild-plugin-lightningcss-modules

Yet another (minimal) css modules plugin using parcels rust based lightningcss implementation. (Full support for composes: mixin from "./mixin.module.css")

The plugin is already tested (on linux and mac) and used to build the following bigger project https://github.com/neos/neos-ui with around 100 css modules - it is inlined in the project though to reduce dependencies and maintaining burdens for now.

Yes sorry, i know there are a few implementions already out there:

  • @asn.aeb/esbuild-css-modules-plugin
  • esbuild-css-modules-plugin
  • esbuild-plugin-css-modules
  • esbuild-style-plugin
  • esbuild-plugin-simple-css-modules

The problem is, they dindt suit my usecase as i needed support for css modules composes feature https://github.com/css-modules/css-modules#dependencies composes: mixin from './mixin.module.css';

The above implementations mostly rely on post-cssmodules and thus dont sucessfully support composition from dependencies as they suffer from this problem: https://github.com/g45t345rt/esbuild-style-plugin/issues/16 (The webpack css modules plugin goes to great lenghts to archieve it successfully)

With one exception: esbuild-css-modules-plugin, this plugin uses also lightningcss as its core, but doesnt support composes yet and due to a more complex inject feature it is a bit more complex. I discussed with the maintainer if we would want to merge our two packages but due to limited time and different usecases (https://github.com/indooorsman/esbuild-css-modules-plugin/issues/53) im here to present my super simple implemented css module plugin for esbuild.

Installation

Available on npm: https://www.npmjs.com/package/esbuild-plugin-lightningcss-modules

yarn add esbuild-plugin-lightningcss-modules

Usage

const {cssModules} = require('esbuild-plugin-lightningcss-modules');
const {build} = require('esbuild');

build({
    ...,
    plugins: [
        cssModules(
            {
                // Add your own or other plugins in the "visitor" section see
                // https://lightningcss.dev/transforms.html
                // visitor: myLightningcssPlugin(),
                // customAtRules: { myLigningCssRule1: {...} }
                targets: {
                    chrome: 80 // aligns somewhat to es2020
                },
                drafts: {
                    nesting: true
                },
                // You can set here your own settings for cssModules
                // https://lightningcss.dev/css-modules.html#local-css-variables
                // https://lightningcss.dev/css-modules.html#custom-naming-patterns
                // cssModules: {
                //    dashedIdents: true,
                //    pattern: 'my-company-[name]-[hash]-[local]'
                // },
            }
        )
    ]
})

for further details look into: https://lightningcss.dev/css-modules.html

Advanced options

includeFilter and excludeFilter

These options only exist for odd / legacy codebases. Normally it is asummed that your css module files end with .module.css. If this is not the case, and they end with .css while you still want to exclude certain normal css from beeing treated as css module you can leverage the two filters like this:

includeFilter: /\.css$/,
excludeFilter: /@fortawesome\/fontawesome-svg-core\/|my-normal-css-file\.css|normalize\.css/,

``