modular-css

CSS Modules, but better and usable via Rollup, Vite, Webpack, CLI, PostCSS, or JS API

MIT License

Downloads
29.7K
Stars
288
Committers
24

Bot releases are hidden (Show)

modular-css - v22.1.4

Published by tivac over 5 years ago

22.1.4 (2019-02-16)

Bug Fixes

  • add homepage & repo directory fields (f9c1606)
modular-css - v22.1.0 - Rollup chunking fixed! 🎉

Published by tivac over 5 years ago

Rollup

After a long think and a couple days of tweaking I've got a graph collapsing algorithm that seems to produce stable, optimal results. I think the loops could be tightened up a bit but given how broken my previous version was it seems prudent to push this ASAP.

As part of this process the output names for CSS chunks were changed from the previous "vaguely attempting to follow the entry filename" approach that never worked right and failed mightily on [hash] templates to "use the last file in the CSS chain". It's a little less useful in some cases but it should always work and be significantly less surprising than the previous behavior.

Processor

This release also introduces a new api for Processor instances, .normalize(). Sometimes you just need to see a file path the way all the internal APIs will!

AND

AND

I finally fixed the long-standing bug where removed composes declarations would leave around extra trailing whitespace & a newline. That had been bothering me for ever so I was thrilled at how easy it was to fix.

.foo {
-    
    color: red;
}

Changelog

22.1.1 (2019-02-06)

Bug Fixes

  • force rollup output to use .css (#563) (8f4348e)
  • work around rollup-pluginutils globbing cwd (4c0bdd8)

22.1.0 (2019-02-06)

Bug Fixes

  • invalidate files when they're changed (cb34c08)
  • log file invalidations (0b1476e)
  • remove newlines after composes (#561) (23569dc)

Features

modular-css - v21.1.1 - Polishing up the rollup-rewriter

Published by tivac over 5 years ago

Mostly fixing some bugs uncovered when using it against a bigger project. Seems fully-functional now and already dropping load times and overall payload sizes for us!

Changelog

21.1.1 (2019-01-21)

Bug Fixes

21.1.0 (2019-01-21)

Features

21.0.1 (2019-01-18)

Bug Fixes

modular-css - v21.0.0 - Metadata output & circular dependency support

Published by tivac almost 6 years ago

Another release focused on @modular-css/rollup because... well it's the one I use the most 😅

Changelog

21.0.0 (2019-01-18)

Bug Fixes

Features

BREAKING CHANGES

  • The previous release would stick all unreferenced CSS at the beginning of the first bundle. This was a mistake, and has been rectified.
modular-css - v20 - Rollup chunk naming & source map fixes

Published by tivac almost 6 years ago

Another major release to fix some rollup bugs. I swear I'll get that right someday.

Changelog

20.0.0 (2019-01-15)

Bug Fixes

BREAKING CHANGES

  • Source maps are written directly to the filesystem now, instead of going through rollup's asset pipeline. This is due to some limitations inherent in how the asset pipeline works and may be changed back once those can be resolved.
modular-css - v19.2.0 - Small Webpack Release

Published by tivac almost 6 years ago

Quick release to add a new feature, passing an already-populated Processor instance to webpack! Huge thanks to @kevinkace for bringing that in, I'm sure it'll be very useful to folks working in mixed environments!

Change Log

19.2.0 (2019-01-11)

Features

  • Update Webpack plugin to accept existing processor (#535) (15f1e15)
modular-css - Bug Bash

Published by tivac almost 6 years ago

Fixed a few bugs, made a cleaner error, and added a small feature to help for checking to see if a Processor instance knows about a file. It's small feature release day! 🎉

Change Log

19.1.0 (2019-01-10)

Bug Fixes

  • better error if resolver returns bad file (513c2a9)
  • check for files via processor.has() (b5a539b), closes #533
  • remove random async from processor.string (d5ca5c0)
  • rollup outputs non .css files in the correct order (2b8fec6)

Features

  • add processor.has to check for known files (df5ac6f)
modular-css - v19 - Now with [email protected] support

Published by tivac almost 6 years ago

The release of [email protected] required some reworking in the rollup plugin, and since it's a breaking peerDependency change due to API changes here we are at v19.

There's some other small under-the-cover improvements like processor.invalidate() but the rollup stuff is the big one.

Change Log

19.0.0 (2019-01-01)

Features

BREAKING CHANGES

modular-css - Rollup code-splitting fixes 🎉

Published by tivac almost 6 years ago

With the release of [email protected] there's now some very useful information passed to plugins that allows @modular-css/rollup to do a much better job of chunking up CSS to match the chunks rollup creates when code-splitting!

And since it's just after midnight & now officially my first day of winter vacation, what better time to release it?

Oh, important note. @modular-css/processor contains a fix for a really nasty timing issue when adding files to the processor. I highly recommend the upgrade even if you don't use rollup!

v18.0.0 Changelog (2018-12-22)

Features

BREAKING CHANGES

  • changed rollup plugin CSS output so it better matches rollup output chunk format & bumped minimum rollup version to 0.68.0
modular-css - Fix svelte @value support

Published by tivac almost 6 years ago

Small release, only real change was to make the @modular-css/svelte preprocessor correctly inject @values into templates.

Bug Fixes

  • tweak value support in svelte preprocessor (7cc0f22)
modular-css - Rollup & Svelte get verbose support

Published by tivac about 6 years ago

verbose has been an option in @modular-css/processor for a couple of months, but now some of the more user-facing bits are getting support!

In this release you can set verbose : true for either @modular-css/rollup or @modular-css/svelte and you'll get logging for both of them as well as the underlying @modular-css/processor object.

So if things aren't working the way you expected, hopefully this helps you figure out why!

modular-css - New rollup option: dev mode!

Published by tivac about 6 years ago

@modular-css/rollup got a new feature this time around, Proxies! (See #516 for the original request and #518 for the PR).

Here's the relevant snippet from the README:

dev

Enable dev mode. In dev mode the default export of a CSS file will be a Proxy instead of a bare object. Attempts to access non-existant properties on the proxy will throw a ReferenceError to assist in catching invalid usage.

The change in output from a CSS file looks something like this (pretend namedExports is disabled for ease of comparison)

- export default {
+ const data = {
    "foo" : "foo",
    "bar" : "foo bar"
};

+ export default new Proxy(data, {
+     get(tgt, key) {
+         if(key in tgt) {
+             return tgt[key];
+         }
+ 
+         throw new ReferenceError(
+             key + " is not exported by " + "your/css/file/here.css"
+         );
+     }
+ });

Proxies have pretty universal support these days but dev defaults to false in case this messed with your workflow. It's intended to be solely additive!

modular-css - NPM org activated!

Published by tivac about 6 years ago

v16.0.0

Important Info

No major changes in this release beyond moving all the packages under the @modular-css npm org.

Previous Package New Package
modular-css-aliases @modular-css/path-aliases
modular-cssify @modular-css/browserify
modular-css-cli @modular-css/cli
modular-css-core @modular-css/processor
modular-css-glob @modular-css/glob
modular-css-namer @modular-css/shortnames
modular-css-paths @modular-css/path-resolver
postcss-modular-css @modular-css/postcss
modular-css-rollup @modular-css/rollup
modular-css-svelte @modular-css/svelte
modular-css-webpack @modular-css/webpack

Other Stuff

  • Doc cleanup, removed most files in /docs in favor of existing package README.md files which were often more up-to-date anyways
  • Cleaned up some of the packages published to npm to have less unused stuff in 'em
modular-css -

Published by tivac over 6 years ago

Features

BREAKING CHANGES

  • Values will now be exported alongside composed classes
modular-css -

Published by tivac over 7 years ago

Fixes #277

modular-css - ES2015 exports

Published by tivac over 7 years ago

See #282 for details

modular-css - Custom file resolvers

Published by tivac over 7 years ago

It's now possible to pass an array of resolvers in as an option when using modular-css. This allows for resolving files in a different way from the default (node file resolution) to support some other use-cases.

For instance, in rollup:

rollup({
    // ...
    plugins : [
        require("modular-css/rollup")({
            css : "./output.css",

            resolvers : [
                (src, file, resolve) => ...
            ]
        })
    ]
})

A resolver function receives three arguments

  • src the file that the inclusion is based off of
  • file the path being included from src
  • resolve the default resolver function, in case that's useful for your resolver
modular-css - Multiple selectors + composition removed

Published by tivac over 7 years ago

During some routine development an issue with how modular-css supported composition arose. See #238 for the gory details, but the short version is that code like the following is no longer supported.

.base { background: blue; }
.one .two .three { composes: base; }

The problem is that there's no sane way to export that w/o causing all sorts of potential overlapping disasters. This was actually called out in the CSS Modules Spec and just slipped through the cracks.

So now code like above will throw an error, sorry 😞

On the plus side webpack support now correctly uses their internal assets system, for whatever that's worth! I'm not 100% sure what benefit it brings but now I don't have to write code to save out files so that's a big 👍🏻 from me.

modular-css - v1.0.0 🎉

Published by tivac almost 8 years ago

It's time, there's finally a webpack plugin and we got a postcss plugin along for the ride.

No other features in this update, but those two are pretty good so I think this is a good time for v1.0.0. 👋

modular-css - Selector namespaces and :external(...)

Published by tivac almost 8 years ago

This is a big feature release, mostly.

1. Namespaced selectors

This is a simple way to avoid namespace collisions between @values you need to import. See https://github.com/tivac/modular-css/issues/207 and https://github.com/tivac/modular-css/pull/210 for more details.

@value * as ns from "./file.css"

.a {
    composes: ns.b;
}

2. :external(...)

A way to override styling on selectors from other files. https://github.com/tivac/modular-css/pull/212

/* Source CSS */
.one {
    color: red;
}

.two :external(one from "./one.css") {
    color: blue;
}

/* Result CSS */
.mc56537f08_one {
    color: red;
}

.mc04cb4cb2_two .mc56537f08_one {
    color: blue;
}