Skip to content

Updating clsx version and using lite module to lower bundle size #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ By default the plugin will remove unnecessary function calls and if all calls ar
Example of some unnecessary calls

```javascript
import clsx from 'clsx';
import clsx from 'clsx/lite';
const x = clsx('foo', 'bar');
const y = clsx({ classA: foo === 'a', classB: foo !== 'a' });
const z = clsx({
Expand Down
2 changes: 1 addition & 1 deletion benchmark/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const Benchmark = require('benchmark');
const path = require('path');
const fs = require('fs');
const clsx = require('clsx');
const clsx = require('clsx/lite');
const classnames = require('classnames');

function bench(name, { title, before, after }) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"babel-plugin-tester": "^7.0.3",
"benchmark": "^2.1.4",
"classnames": "^2.2.6",
"clsx": "^1.0.4",
"clsx": "^2.1.0",
"husky": "^4.2.3",
"jest": "^24.9.0",
"prettier": "^2.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const DefaultSettings = {
libraries: ['clsx', 'classnames'],
libraries: ['clsx/lite', 'classnames'],
functionNames: [] as string[],
removeUnnecessaryCalls: true,
collectCalls: false,
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/find-function-names/namespace-import/code.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import * as clsx from 'clsx';
import * as clsx from 'clsx/lite';

clsx({ foo: true });
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import * as clsx from 'clsx';
import * as clsx from 'clsx/lite';
clsx('foo');
2 changes: 1 addition & 1 deletion test/fixtures/find-function-names/unused-import/code.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import clsx from 'clsx';
import clsx from 'clsx/lite';
const cn = require('classnames');

const x = clsx('foo');
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/find-function-names/using-import/code.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import fooFunction from 'clsx';
import fooFunction from 'clsx/lite';

fooFunction({ foo: true });
2 changes: 1 addition & 1 deletion test/fixtures/find-function-names/using-import/output.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import fooFunction from 'clsx';
import fooFunction from 'clsx/lite';
fooFunction('foo');
2 changes: 1 addition & 1 deletion test/fixtures/find-function-names/using-require/code.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const fooFunction = require('clsx');
const fooFunction = require('clsx/lite');

fooFunction({ foo: true });
2 changes: 1 addition & 1 deletion test/fixtures/find-function-names/using-require/output.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const fooFunction = require('clsx');
const fooFunction = require('clsx/lite');

fooFunction('foo');
2 changes: 1 addition & 1 deletion test/fixtures/proptypes/member-access/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from 'clsx/lite';
import PropTypes from 'prop-types';
import clsx from 'clsx';

function foo(props) {
const x = clsx(props.position === 'top' && classes.x, props.position === 'bottom' && classes.y);
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/proptypes/member-access/output.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from 'clsx/lite';
import PropTypes from 'prop-types';
import clsx from 'clsx';

function foo(props) {
const x = clsx(props.position === 'top' ? classes.x : classes.y);
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/proptypes/object-pattern-assignment/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from 'clsx/lite';
import PropTypes from 'prop-types';
import clsx from 'clsx';

function foo(props) {
const { position = 'top', anchor: a = 'left' } = props;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from 'clsx/lite';
import PropTypes from 'prop-types';
import clsx from 'clsx';

function foo(props) {
const { position = 'top', anchor: a = 'left' } = props;
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/proptypes/object-pattern-inline/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from 'clsx/lite';
import PropTypes from 'prop-types';
import clsx from 'clsx';

function foo({ position: p }) {
const x = clsx(p === 'top' && classes.x, p === 'bottom' && classes.y);
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/proptypes/object-pattern-inline/output.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from 'clsx/lite';
import PropTypes from 'prop-types';
import clsx from 'clsx';

function foo({ position: p }) {
const x = clsx(p === 'top' ? classes.x : classes.y);
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/proptypes/object-pattern-rest/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from 'clsx/lite';
import PropTypes from 'prop-types';
import clsx from 'clsx';

function foo(props) {
const { position: p, ...rest } = props;
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/proptypes/object-pattern-rest/output.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from 'clsx/lite';
import PropTypes from 'prop-types';
import clsx from 'clsx';

function foo(props) {
const { position: p, ...rest } = props;
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/proptypes/object-pattern/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from 'clsx/lite';
import PropTypes from 'prop-types';
import clsx from 'clsx';

function foo(props) {
const { position: p } = props;
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/proptypes/object-pattern/output.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from 'clsx/lite';
import PropTypes from 'prop-types';
import clsx from 'clsx';

function foo(props) {
const { position: p } = props;
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/proptypes/variable-declaration/code.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from 'clsx/lite';
import PropTypes from 'prop-types';
import clsx from 'clsx';

function foo(props) {
const p = props.position;
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/proptypes/variable-declaration/output.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from 'clsx/lite';
import PropTypes from 'prop-types';
import clsx from 'clsx';

function foo(props) {
const p = props.position;
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/referenced-object/transformed-callee/code.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import clsx from 'clsx';
import clsx from 'clsx/lite';

const stateClasses = {
checked: isChecked,
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/referenced-object/transformed-callee/output.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';

var _clsx = _interopRequireDefault(require('clsx'));
var _lite = _interopRequireDefault(require('clsx/lite'));

function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}

const stateClasses = (0, _clsx.default)(isChecked && 'checked');
(0, _clsx.default)(stateClasses);
const stateClasses = (0, _lite.default)(isChecked && 'checked');
(0, _lite.default)(stateClasses);
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1967,7 +1967,7 @@ __metadata:
babel-plugin-tester: ^7.0.3
benchmark: ^2.1.4
classnames: ^2.2.6
clsx: ^1.0.4
clsx: ^2.1.0
find-cache-dir: ^3.2.0
husky: ^4.2.3
jest: ^24.9.0
Expand Down Expand Up @@ -2316,10 +2316,10 @@ __metadata:
languageName: node
linkType: hard

"clsx@npm:^1.0.4":
version: 1.0.4
resolution: "clsx@npm:1.0.4"
checksum: bd2a74dbc2fa10d44c5cb083d2ed65da098fd9bc502af767c723becd2f2acb9f09824aac13ed871e93d4afa7c8af5c68b9f3ec99581de157aae7aeee2aca7d2e
"clsx@npm:^2.1.0":
version: 2.1.0
resolution: "clsx@npm:2.1.0"
checksum: 43fefc29b6b49c9476fbce4f8b1cc75c27b67747738e598e6651dd40d63692135dc60b18fa1c5b78a2a9ba8ae6fd2055a068924b94e20b42039bd53b78b98e1d
languageName: node
linkType: hard

Expand Down