CSS Modules, but better and usable via Rollup, Vite, Webpack, CLI, PostCSS, or JS API
MIT License
Bot releases are hidden (Show)
Published by tivac over 5 years ago
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.
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;
}
Published by tivac over 5 years ago
Published by tivac almost 6 years ago
Another release focused on @modular-css/rollup
because... well it's the one I use the most 😅
Published by tivac almost 6 years ago
Another major release to fix some rollup bugs. I swear I'll get that right someday.
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!
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! 🎉
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.
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!
Published by tivac almost 6 years ago
Small release, only real change was to make the @modular-css/svelte
preprocessor correctly inject @value
s into templates.
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!
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 aReferenceError
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!
Published by tivac about 6 years ago
No major changes in this release beyond moving all the packages under the @modular-css npm org.
/docs
in favor of existing package README.md
files which were often more up-to-date anywaysPublished by tivac over 7 years ago
See #282 for details
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 offile
the path being included from src
resolve
the default resolver function, in case that's useful for your resolverPublished 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.
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
. 👋
Published by tivac almost 8 years ago
This is a big feature release, mostly.
This is a simple way to avoid namespace collisions between @value
s 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;
}
: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;
}