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

Do not include momentjs in the browser bundle if DatePicker and/or TimePicker are not used #20579

Closed
1 task done
lhz516 opened this issue Jan 2, 2020 · 5 comments · Fixed by lhz516/hanzluo-legacy#3
Closed
1 task done
Assignees

Comments

@lhz516
Copy link
Contributor

lhz516 commented Jan 2, 2020

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

https://github.com/lhz516/hanzluo

Steps to reproduce

  1. npm i antd, but don't import momentjs related components
  2. Use webpack to bundle the app

What is expected?

moment won't be included in the browser bundle if DatePicker and/or TimePicker are not used

What is actually happening?

moment is in the browser bundle no matter if DatePicker and/or TimePicker are used. At least the locales shouldn't be included.
image

Run npm ls moment
image

Environment Info
antd 3.26.3 (Also tested 3.26.5)
React 16.12.0
System Win 10
Browser Any
@afc163
Copy link
Member

afc163 commented Jan 2, 2020

It should be fixed in #19115 already.

@lhz516
Copy link
Contributor Author

lhz516 commented Jan 2, 2020

@afc163 I already set mode: 'production' in my webpack config. I assume the tree shaking is enabled. Is there anything else I need to do to get rid of these unnecessary modules?

@afc163
Copy link
Member

afc163 commented Jan 2, 2020

https://github.com/lhz516/hanzluo/pull/3

@afc163 afc163 closed this as completed Jan 2, 2020
@zombieJ

This comment has been minimized.

lhz516 pushed a commit to lhz516/hanzluo-legacy that referenced this issue Jan 2, 2020
@lhz516
Copy link
Contributor Author

lhz516 commented Jan 2, 2020

@zombieJ Tree shaking worked by adding libraryDirectory: 'es' into babel-plugin-import's config.

cc: https://github.com/lhz516/hanzluo/pull/3 @afc163

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

Successfully merging a pull request may close this issue.

3 participants