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

[ADS-645] Remove extra chunk and make moment external #686

Merged
merged 1 commit into from
Jan 23, 2018
Merged

Conversation

sonhanguyen
Copy link
Contributor

@sonhanguyen sonhanguyen commented Jan 11, 2018

Description

  • Remove the extra bundle
  • Externalizing momentjs

Motivation and Background Context

  • Currently, the build generates 3 bundles: "core", "extra" (that contains react-datepicker) and "main" that has everything. The splitting was done mainly because react-datepicker has momentjs bundled which we don't use but Symphony does, and moment's size is considerable.
  • direct-web however has not switched to only import core, so moment code is duplicated anyway.

Does this PR introduce a breaking change?

for SYMPHONY in case they don't already have moment as a dependency, If they do this saves them 240K as well

  • Yes
  • No

How Has This Been Tested?

Screenshots (if appropriate):

Check-list:

  • I have read the Contributing document.
  • I've thought about and labelled my PR/commit message appropriately.
  • If this PR introduces breaking changes I've described the impact and migration path for existing applications.
  • CI is green (coverage, linting, tests).
  • I have updated the documentation accordingly.
  • I've two LGTMs/Approvals.
  • I've fixed or replied to all my code-review comments.
  • I've manually tested with a buddy.
  • I've squashed my commits into one.

@codecov-io
Copy link

codecov-io commented Jan 11, 2018

Codecov Report

Merging #686 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #686   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          53     53           
  Lines         776    776           
  Branches      154    154           
=====================================
  Hits          776    776

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 072b1de...2c49eb6. Read the comment docs.

@sonhanguyen sonhanguyen changed the title Update: remove extra chunk and make moment external [ADS-645] Remove extra chunk and make moment external Jan 11, 2018
@omgaz
Copy link
Contributor

omgaz commented Jan 11, 2018

The issue wasn't with moment it was with moment-tz, and where further breaking changes may appear. Have a look at https://github.com/Hacker0x01/react-datepicker#localization and check localisations.

@omgaz
Copy link
Contributor

omgaz commented Jan 11, 2018

Apart from the comment around localisation, LGTM.

I just have a concern about externalising moment. It's a clear dependency of our code, unlike react which is the framework our code is built upon. I know it saves us some size but it's now required to be installed by a third-party application and not sure if it makes sense (unlike moment-tz) like my last comment mentions.

I still feel it should be an installed dependency.

@sonhanguyen
Copy link
Contributor Author

@omgaz I don't see many problems because moment would be the in same line to lodash by that logic. react-datepicker externalizes it too as a peerDependencies. We initially did import 'react-datepicker/dist/react-datepicke' which wasn't the intended way, that's why it was included.

Copy link
Contributor

@nimishjha nimishjha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks fine, but I'm not familiar with the background here.

@omgaz
Copy link
Contributor

omgaz commented Jan 15, 2018

@sonhanguyen did you send this around for another review?

@@ -1,4 +0,0 @@
import 'styles/_react-datepicker-custom.scss';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by removing these extra entries, you can revert changes made in #672 (see its description)

Copy link
Contributor Author

@sonhanguyen sonhanguyen Jan 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted

Copy link
Contributor

@xiaofan2406 xiaofan2406 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sonhanguyen
Copy link
Contributor Author

@omgaz @xiaofan2406, should we make moment an optional dependency?

@xiaofan2406
Copy link
Contributor

It should be a peerDeps, like react

@sonhanguyen
Copy link
Contributor Author

@xiaofan2406 yeah but peer means required. We happen to have moment in direct-web too, but we didn't include moment because of adslot-ui. We don't actually use its datepicker component.

@sonhanguyen
Copy link
Contributor Author

@omgaz what do you think about react as a peerDep, seems like the way most projects do it.

@omgaz
Copy link
Contributor

omgaz commented Jan 15, 2018

moment is a requirement so it does make sense for it to be a peer dependency like react, but we can deal with it in another PR.

Also, we do use the react-datepicker in all projects.

@xiaofan2406
Copy link
Contributor

I remember peer deps will come off as warning not error.

So if a project uses adslot-ui and dont use the date picker component, the project can choose to not to install moment, and other components should be working correctly

@sonhanguyen sonhanguyen force-pushed the remove-extra branch 2 times, most recently from 266424c to 2834b98 Compare January 15, 2018 04:01
Copy link
Contributor

@omgaz omgaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, will merge in a bit. @sonhanguyen looks like we need a rebase; sorry.

@omgaz
Copy link
Contributor

omgaz commented Jan 23, 2018

Rebased for release.

@omgaz omgaz merged commit b918f0b into master Jan 23, 2018
@omgaz omgaz deleted the remove-extra branch January 23, 2018 00:08
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 this pull request may close these issues.

5 participants