Open sergio-bravo opened 5 years ago
Update: Probably it worth a mention in readme that timezone-support requires tree-shaking to be configured.
@sergio-bravo Do you have an example how to get this working with webpack and date-fns-timezone?
Any updates ? How can i exclude unused timezones ?
Webpack config
resolve: {
extensions: ['*', '.js', '.jsx'],
alias: {
'timezone-support$': path.join(__dirname, 'node_modules/timezone-support/dist/index-2012-2022.js')
}
}
@Pagebakers sorry I only saw the question now.
I used webpack tree-shaking guide, not alias
As I can remember it was done in .babelrc
"presets": [["@babel/preset-env", { "modules": false }]]
and `package.json``
"sideEffects": false,
No worries :)
Thanks, this is what I tried at first but it always seemed to include the full timezone database.
I'm having the same issue as the OP. Using this library via date-fns-timezone and getting nearly 1 MB of timezone-support in my production build. I'm building via next.js. Anyone find a fix for this yet?
I'm seeing the same picture and not sure if any of the above mentioned solutions works to bring down the final bundle size? I am using webpack through create-react-app
.
My suggested webpack config works perfect for me.
You could even copy the index-2012-2022.js list and strip out even more relevant data to decrease the size.
It's just that my webpack config is completely vanilla, I have not had the need to do any custom configurations at all to all my packages as they all allow tree shaking — maybe a few do not, but they are so small that the gain would be negligible.
This package should do this out of the box really — especially due to its large size.
I'll try it out, thanks!
Hi. In readme it's said:
In my project I see different picture:
I use it via date-fns-timezone: ^0.1.4