webpack-contrib / mini-css-extract-plugin

Lightweight CSS extraction plugin
MIT License
4.65k stars 390 forks source link

feat: support named exports with any characters #1057

Closed laverdet closed 5 months ago

laverdet commented 9 months ago

A proposed change to css-loader will allow named exports to be any string, regardless of whether or not it is a valid identifier. The code generation in this project assumes that all exports will be a valid identifier, so the generation stage has been updated to take this into account.

This PR contains a:

Motivation / Use-Case

When using the new "asIs" named exports feature I submitted in webpack-contrib/css-loader#1549, this module will produce incorrect output since the export names may not be valid local identifiers.

Breaking Changes

Requires support for export { local as "string literal" } syntax which is not supported until nodejs v16.x.

Additional Info

Named exports resolve the Terser bailout condition described in webpack/webpack#17626 but reduce "grepability" of your code.

linux-foundation-easycla[bot] commented 9 months ago

CLA Signed

The committers listed above are authorized under a signed CLA.

laverdet commented 9 months ago

This is part of a series of pull requests which adds better ecosystem support for exporting original, non-mangled, CSS names as named exports.

webpack-contrib/css-loader#1549 webpack-contrib/mini-css-extract-plugin#1057 seek-oss/css-modules-typescript-loader#50

Due to the optimization bailout condition [webpack/webpack#17626] with JSON default exports consumed by hoistable functions, original non-minified CSS module class names can be found in the minified source code.