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

Weird bundle size in production #14

Open
sergio-bravo opened this issue Jul 9, 2019 · 10 comments
Open

Weird bundle size in production #14

sergio-bravo opened this issue Jul 9, 2019 · 10 comments

Comments

@sergio-bravo
Copy link

Hi.
In readme it's said:

Tiny code base - 4.6 KB minified, 1.7 KB gzipped...

In my project I see different picture:
image

I use it via date-fns-timezone: ^0.1.4

@sergio-bravo
Copy link
Author

Update:
Probably it worth a mention in readme that timezone-support requires tree-shaking to be configured.

@Pagebakers
Copy link

@sergio-bravo Do you have an example how to get this working with webpack and date-fns-timezone?

@AndriiDidkivsky
Copy link

Any updates ?
How can i exclude unused timezones ?

@Pagebakers
Copy link

Webpack config

  resolve: {
    extensions: ['*', '.js', '.jsx'],
    alias: {
      'timezone-support$': path.join(__dirname, 'node_modules/timezone-support/dist/index-2012-2022.js')
    }
}

@sergio-bravo
Copy link
Author

@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,

@Pagebakers
Copy link

No worries :)

Thanks, this is what I tried at first but it always seemed to include the full timezone database.

@mattdodge
Copy link

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?

@houmark
Copy link

houmark commented Nov 21, 2019

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.

@Pagebakers
Copy link

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.

@houmark
Copy link

houmark commented Nov 22, 2019

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!

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

5 participants