Skip to content
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

Bundle size increased after the upgrade #648

Open
shalineepatel opened this issue Jun 6, 2024 · 0 comments
Open

Bundle size increased after the upgrade #648

shalineepatel opened this issue Jun 6, 2024 · 0 comments

Comments

@shalineepatel
Copy link

The bundle size of the project has increased after the upgrade

With the v2.0.1, it added date-fns chunk which wasn't in there before with react-date-range v1.4.0

We have a 'DatePickerRange' implemented in our project as below

import "react-date-range/dist/styles.css"; // main css file
import "react-date-range/dist/theme/default.css"; // theme css file
import { DateRangePicker, defaultInputRanges, defaultStaticRanges } from "react-date-range";
const DateFilter: React.FC = () => {
const [state, setState] = React.useState([
{
startDate: null,
endDate: null,
key: "selection"
}
]);
return (
<DateRangePicker
style={{ minHeight: 270 }}
direction="horizontal"
showSelectionPreview={true}
dateDisplayFormat={"dd MMM yyyy"}
months={2}
weekStartsOn={1}
rangeColors={["rgb(104, 54, 139)"]}
onChange={(item: any) =>
setState([
{
startDate: item.range1.startDate,
endDate: item.range1.endDate
}
])
}
ranges={[
{ startDate: state[0].startDate, endDate: state[0].endDate }
]}
inputRanges={[defaultInputRanges[0]]}
staticRanges={[
{
...defaultStaticRanges[2],
range: () => ({
startDate: startOfISOWeek(new Date()),
endDate: new Date()
})
},
{
...defaultStaticRanges[3],
range: () => ({
startDate: startOfISOWeek(addDays(new Date(), -7)),
endDate: endOfISOWeek(addDays(new Date(), -7))
})
}
]}
/>
);
};

image

[BUG] Expected behavior

It shouldn't include the date-fns chunk as before, or only the imports from the components used in the project. Right now it imports everything. (See the attached file)

Environment

Package Version: 2.0.1
React version: 18.2.0
Node version: 18.12.1
Browser: Google Chrome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant