webpack.js.org icon indicating copy to clipboard operation
webpack.js.org copied to clipboard

Document webpack change: feat(css): allow to use default and named export

Open webpack-bot opened this issue 1 year ago • 0 comments

A pull request by @alexander-akait was merged and maintainers requested a documentation change.

See pull request: https://github.com/webpack/webpack/pull/18271


What kind of change does this PR introduce?

feature - allow to use default and named export

The same as requested here - https://github.com/webpack-contrib/mini-css-extract-plugin/pull/1084

/cc @ahabhgk What do you think about it?

The main idea - allow to easy migrate from default to named, by default it is disabled (because we use only named export), but if developers have a lot of code, it is not easy to migrate fast, so developer can disable named export and use both of them

Did you add tests for your changes?

Yes

Does this PR introduce a breaking change?

No

What needs to be documented once your changes are merged?

When named export is disabled for CSS modules you can get classes using (we redirect named export for better DX, it will allow to migrate from default export to named smoothly):

import * as styles from "./styles.css";
import styles1 from "./styles.css";
import { foo } from "./styles.css";

console.log(styles.default.foo);
console.log(styles.foo);
console.log(styles1.foo);
console.log(foo);

When namedExport: true, you can use only named export.

webpack-bot avatar Apr 02 '24 15:04 webpack-bot