Packages

clsx

2.1.1 · 23 Apr 2024MIT179.1M / weekRepositoryHomepagenpmAtom feed

Your version

14 stable releases, newest first, by release line. Notes are quoted as the maintainers published them.

  1. 2.x · latest line
  2. 2.1.1

    23 Apr 2024
  3. 2.1.0

    29 Dec 2023
    • Add new clsx/lite submodule for string-only usage: 1a49142

      This is a 140b version of clsx that is ideal for Tailwind and/or React contexts, which typically follow this clsx usage pattern:

      clsx('foo bar', props.maybe && 'conditional classes', props.className);

      Important: This clsx/lite module ignores all non-string arguments and is therefore not a 1:1 replacement for clsx itself!

      import { clsx } from 'clsx';
      import { clsx as lite } from 'clsx/lite';
      
      // strings-only usage is identical
      clsx('foo', null, 'bar', true && 'baz'); //=> "foo bar baz"
      lite('foo', null, 'bar', true && 'baz'); //=> "foo bar baz"
      
      // clsx/lite ignores all non-strings
      clsx('foo', { a: true, b: false, c: true }); //=> "foo a c"
      lite('foo', { a: true, b: false, c: true }); //=> "foo"
  4. 2.0.1

    29 Dec 2023
    • (perf) Cache arguments.length & array.length for 6% performance gain (#26): deff09b
      Adds 5 bytes (+2%) for ~3% avg performance gain
      Thank you @jalalazimi

  5. 2.0.0

    15 Jul 2023
    • Breaking

      Add "exports" map for native ESM support (#57): 3ec8e9f, 0949868
      Also supports TypeScript's node16/nodenext module resolution
      Maintains CommonJS support (with fixed TS definitions)
      Thank you @remcohaszing~!

  6. 1.x
  7. 1.2.1

    6 Jul 2022
    • Ensure CommonJS and UMD entrypoints have the named clsx export too

  8. 1.2.0

    2 Jul 2022
    • Add named clsx export alias (#43, #44): 56ab81f
      Thank you @danikaze~!
      This is purely an alias for the default export so that TypeScript users can avoid the esModuleInterop setting. In other words, the follow import statements are effectively identical, but the latter is preferred by TypeScript:

      import clsx from 'clsx';
      // or
      import { clsx } from 'clsx';

      Important: Just to reiterate, both still work!

  9. 1.1.1

    30 May 2020
    • Remove needless spacer on string/number condition: ff11464

    • Remove unnecessary recursive caller for object keys: f43dd23

    • Guard all toVal calls with truthy assertions: 4fa8811, 019ec02

  10. 1.1.0

    3 Feb 2020
    • Use Array.isArray for proper Array type-checking (#17): 0d6023a

      This prevents an object with a truthy push key from being treated as an Array. While (likely) rare, this produced an incorrect result.

      Important: Because of this change, Internet Explorer 8 (and older) are no longer supported.If you happen to require support for these browsers, please continue to use the 1.0.x version range.

  11. 1.0.4

    6 Apr 2019
    • Ignore function arguments: 4aff569

    • Separate Array and Object loops: 91f5e68

      While this did add ~20 bytes to the package (which is a 10% size increase), it made any Array interactions 200% to 600% faster! 🎉 Below is a performance comparison between clsx@1.0.3 and clsx@1.0.4 running on Node v10.13.0:

      # Strings
        clsx (prev)  x 10,661,038 ops/sec ±0.46% (92 runs sampled)
        clsx         x 11,066,632 ops/sec ±0.23% (96 runs sampled)
      
      # Objects
        clsx (prev)  x 6,934,269 ops/sec ±0.23% (94 runs sampled)
        clsx         x 7,147,168 ops/sec ±0.30% (95 runs sampled)
      
      # Arrays
        clsx (prev)  x 1,681,568 ops/sec ±0.32% (97 runs sampled)
        clsx         x 7,922,225 ops/sec ±0.18% (95 runs sampled)
      
      # Nested Arrays
        clsx (prev)  x   940,741 ops/sec ±0.33% (96 runs sampled)
        clsx         x 6,132,222 ops/sec ±0.49% (95 runs sampled)
      
      # Nested Arrays w/ Objects
        clsx (prev)  x 1,428,975 ops/sec ±0.15% (95 runs sampled)
        clsx         x 5,156,844 ops/sec ±0.22% (95 runs sampled)
      
      # Mixed
        clsx (prev)  x 2,198,907 ops/sec ±0.34% (98 runs sampled)
        clsx         x 5,577,715 ops/sec ±0.20% (93 runs sampled)
      
      # Mixed (Bad Data)
        clsx (prev)  x 1,038,752 ops/sec ±0.32% (94 runs sampled)
        clsx         x 1,887,010 ops/sec ±0.14% (96 runs sampled)
  12. 1.0.3

    18 Feb 2019
    • Changed "module" entry file to .js extension (#7): 29b2fce

      Unfortunately, webpack changed how they treat .mjs files somewhat recently. This is a huge step backwards and hopefully they revert this change soon. See #894

  13. 1.0.2

    3 Feb 2019
  14. 1.0.1

    11 Jan 2019
  15. 1.0.0

    25 Dec 2018
  16. 0.0.x
  17. 0.0.1

    24 Dec 2018

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.