tivac / modular-css

CSS Modules, but better and usable via Rollup, Vite, Webpack, CLI, PostCSS, or JS API
http://m-css.com
MIT License
288 stars 19 forks source link

svelte preprocessor is too greedy #432

Closed tivac closed 6 years ago

tivac commented 6 years ago
<link rel="stylesheet" href="./style.css" />

<!-- correctly transformed -->
<div class="{css.foo}">Foo</div>

<script>
const data = {
    field : "foo"
};

// Incorrectly transformed
const style = css[data.field];
</script>
tivac commented 6 years ago

Need to add more detail, this isn't actually enough to repro yet.

tivac commented 6 years ago

The issue happens when you have a structure like css[foo.bar] where foo is a valid key in the css object.

const style = "fooga wooga bd".flex];

is what ends up in the output.