bem / bem-react

A set of tools for developing user interfaces using the BEM methodology in React
http://bem.github.io/bem-react
Other
440 stars 64 forks source link

fix(build): fix minification issues in classname pkg #606

Closed gridsane closed 3 years ago

gridsane commented 3 years ago

We found an issue in the .min build of @bem-react/classname package.

classname.development.js:

cn('block')({ mod: '1' }) // block__mod_1

classname.production.min.js:

cn('block')({ mod: '1' }) // block__mod

This happens because of booleans_as_integers terser option.

This expression:

if (modVal === true) {
    className += modPrefix + k;
} else {
    <...>
}

Transforms to:

1 == p ? v += u + s : <...>

It's impossible to use mod values '1' or 1 with such transform.

Full diff with and without booleans_as_integers option: https://www.diffchecker.com/2XzvNEZg

gridsane commented 3 years ago

@yarastqt could you please publish @bem-react/classname with this fix?

yarastqt commented 3 years ago

Available start from:

 - @bem-react/classname@1.5.11
 - @bem-react/classnames@1.3.10
 - @bem-react/core@3.0.7
 - @bem-react/di@2.2.7