Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Bundle size increased after the upgrade #648

@shalineepatel

Description

@shalineepatel

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions