-
I have a simple setup with Create React App (CRA) v5.0. All my imports are of this form: import { parseISO } from "date-fns"; I'm not importing anything form "date-fns/locale" (or any other sub branch of date-fns). I only need EN/US for this app. When I do a production build and analyze with source-map-explorer, this is what I see: I've read the issues and other discussions here on bundle size, but haven't come across a solution to my particular problem (at least without ejecting CRA, which I hope is not necessary). What could I be doing wrong? Related: #3004 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @devuxer, Can't reproduce the problem over here with CRA 5.0.1, date-fns 2.28, source-map-explorer 2.5.2 and this small demo app: // src/App.js
import { format, parseISO } from 'date-fns';
function App() {
return (
<>
<div>Current date: {format(new Date(), 'yyyy-MM-dd')}</div>
<div>Parse: {parseISO('2022-05-14').toLocaleString()}</div>
</>
);
}
export default App;
Something in your app must be importing locales, because the library itself only references en-US and only does so for functions with a locale option.
Some ideas to investigate:
Maybe you can share your package.json file, or even better put together the smallest possible app that manages to reproduce the problem. Hope that helps. |
Beta Was this translation helpful? Give feedback.
Hi @devuxer,
Can't reproduce the problem over here with CRA 5.0.1, date-fns 2.28, source-map-explorer 2.5.2 and this small demo app:
Something in your app must be importing locales, because the library itself only references en-US and only does so for functions with a locale option.
Some ideas to investigate: