developit / microbundle

📦 Zero-configuration bundler for tiny modules.
https://npm.im/microbundle
MIT License
8.04k stars 362 forks source link

css modules default flag doesnt work? #932

Closed leon-up9 closed 2 years ago

leon-up9 commented 2 years ago

styles.sass is still parsed as css module. only using --css-modules false works.

expected behavior : to compile as a module only the module.sass extention

when used in a code :

//index.module.sass
.test

// app.tsx
import styles from "./index.module.sass"

 <span className={styles.test}>123213</span>

and not complie regular index.sass as modules

which used as:

//index.sass
.test

// app.tsx
import  "./index.sass"

 <span className="test">123213</span>

any workaround?

rschristian commented 2 years ago

I cannot reproduce this, and your comment seems to be contradictory. Your "how used in a code" snippet shows exactly how you'd use a CSS module, so if you don't want that behavior, I don't see why you'd be writing that.

Even setting --css-modules to true won't break this, as you're using a side-effectual import. There's no way for this to be treated as a module.

// index.jsx
import './styles.sass';

export default function Foo() {
    return <h1 class="test">Hello World</h1>
}
// styles.sass
.test
  color: blue
leon-up9 commented 2 years ago

I cannot reproduce this, and your comment seems to be contradictory. Your "how used in a code" snippet shows exactly how you'd use a CSS module, so if you don't want that behavior, I don't see why you'd be writing that.

Even setting --css-modules to true won't break this, as you're using a side-effectual import. There's no way for this to be treated as a module.

// index.jsx
import './styles.sass';

export default function Foo() {
    return <h1 class="test">Hello World</h1>
}
// styles.sass
.test
  color: blue

i have edited my question and tried to clerify. when i have a similiar code to your example it still compiles as a module.(which should not, corrent?) and since in the html the class name is test and not .h45gy (for example) the style is not applied

rschristian commented 2 years ago

You'll need to provide a reproduction. I cannot follow from your description.

What I provided does not get treated as a module.

rschristian commented 2 years ago

Closing due to no response and not enough information to go on.