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

Upgrading deps #446

Merged
merged 11 commits into from
Apr 17, 2018
Merged

Upgrading deps #446

merged 11 commits into from
Apr 17, 2018

Conversation

alexreardon
Copy link
Collaborator

No description provided.

@@ -1,21 +1,21 @@
{
"dist/react-beautiful-dnd.js": {
"bundled": 372617,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Main code change i can see is our moving from throw new Error to invariant in an attempt to reduce kb's in tree shaking. However, it looks like our umd bundle went up. Any thoughts @TrySound ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't know to be honest.

@lukastaegert what was changed in the latest versions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I updated the snapshot on master so we are sure we are looking at the correct thing

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had a look at the build and it is not creating multiple copies of invariant..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it might be a transitive dependency change..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, i reversed the invariant usages changes and i can confirm that the size changes did not come from there

@@ -364,15 +364,15 @@ export type DropState = {|
result: ?DropResult,
|}

export type State = {
export type State = {|
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

now an exact type

"gzipped": 35556
"bundled": 360109,
"minified": 132835,
"gzipped": 37619
},
"dist/react-beautiful-dnd.esm.js": {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

our esm builds are looking better for moving to invariant rather than throwing, but otherwise we took a huge hit!

Choose a reason for hiding this comment

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

What is the reason for using invariant over throw statements? Did you notice any effect on Flow's ability to narrow the types on things?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here is the reason for using invariant:

 * The invariant message will be stripped in production, but the invariant
 * will remain to ensure logic does not differ in production.

Flow understands that invariant will throw if the condition is not met

"raf-stub": "^2.0.2",
"react": "^16.3.1",
"react-dom": "^16.3.1",
"react-test-renderer": "^16.3.1",
"rimraf": "^2.6.2",
"rollup": "^0.56.2",
"rollup": "^0.58.0",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

could this be the cause?

[email protected], babylon@^7.0.0-beta.40:
version "7.0.0-beta.42"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.42.tgz#67cfabcd4f3ec82999d29031ccdea89d0ba99657"
[email protected]:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This might also be the cause

rollup@^0.56.2:
version "0.56.5"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.56.5.tgz#40fe3cf0cd1659d469baad11f4d5b6336c14ce84"
rollup@^0.58.0:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this could have caused it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nah i just checked

@alexreardon
Copy link
Collaborator Author

Given that the regression is only for the UMD bundle i am tentatively okay to proceed.

We cannot reasonably stay on old deps to avoid the kb hit.

Although i do think it very worthwhile to investigate the cause.

Any takers @lukebatchelor @TrySound ?

"babel-cli": "^6.26.0",
"babel-eslint": "^8.2.1",
"babel-core": "^6.26.0",

Choose a reason for hiding this comment

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

No babel-core before this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it was being brought in by another dep. now we are being more explicit

@@ -134,10 +134,11 @@ export const scrollDroppable = (
clipped,
};

return ({
const result: DroppableDimension = {

Choose a reason for hiding this comment

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

Does flow complain without this cast?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nope! it now works with exact types and spread

@@ -266,13 +266,13 @@ export default (state: State = clean('IDLE'), action: Action): State => {
return existing;
}

const newDrag: DragState = ({
const newDrag: DragState = {

Choose a reason for hiding this comment

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

Could clean up the Flow annotations by typing this IIFE like:

const drag = ((): ?DragState => {
  // ...
})();

@lukebatchelor
Copy link
Member

So, looking at the diff of the two bundles (before and after this PR) I get an interesting result.

Immediately I see the new bundle has invariant bundled at the top and in each place the old bundle has a null check and a throw, the new bundle has a call to invariant.

Strangely, further down I do then see a copy of invariant in the old bundle though (one that is not included in the new bundle)... So.. You would assume these would cancel each other out no?

Also, all of invariant including the license header is 1.4k, a lot less that the 38k difference we are seeing reported?

Overall, just looking at the diff, if anything I would actually expect the old bundle to be bigger... I'll show you the diff when you're around.

@lukebatchelor
Copy link
Member

Oh, also worth noting, the actual sizes I'm getting don't match the output above

$ cat original.js | wc -c
372696

$ cat new.js | wc -c
372551

$ echo "372696 - 372551" | bc
145

Only 145 bytes difference.

@@ -44,7 +44,6 @@
},
"dependencies": {
"babel-runtime": "^6.26.0",
"invariant": "^2.2.4",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

gone!!!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wrote my own. I will put it on npm soon.

@@ -44,7 +44,6 @@
},
"dependencies": {
"babel-runtime": "^6.26.0",
"invariant": "^2.2.4",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wrote my own. I will put it on npm soon.

src/invariant.js Outdated
@@ -0,0 +1,21 @@
// @flow

const isProduction: boolean = process.env.NODE_ENV === 'production';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

why complicate things? a super simple invariant function that actually works

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have tested the bundles and the messages are now being stripped correctly

"memoize-one": "^3.1.1",
"prop-types": "^15.6.0",
"raf-schd": "^2.1.1",
"react-motion": "^0.5.2",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0",
"reselect": "^3.0.1"
"reselect": "^3.0.1",
"tiny-invariant": "^0.0.3"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

right now i have not figured out how to get our rollup build to tree shake the env conditional insight of this module. However, i am happy to solve that later

@alexreardon
Copy link
Collaborator Author

I have no idea where the extra 27,156 bytes came from... I had a look at the diff and i cannot see how we got such an increase

Original

cat dist/react-beautiful-dnd.js | wc -c
  372696

New

cat dist/react-beautiful-dnd.js | wc -c
  399852

@alexreardon
Copy link
Collaborator Author

Given that it will only impact the umd distribution i am okay to proceed at this point. However, it would be worth getting to the bottom of this one

@alexreardon
Copy link
Collaborator Author

This could be relevant:

./src/index.js → dist/react-beautiful-dnd.js...

Computed sizes of "dist/react-beautiful-dnd.js" with "umd" format
  bundled: 399,839 B
  minified with uglify: 149,239 B
  minified and gzipped: 42,623 B


(!) Missing exports
https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module
commonjs-proxy:/Users/areardon/code/react-beautiful-dnd/node_modules/core-js/library/modules/es6.object.to-string.js
default is not exported by node_modules/core-js/library/modules/es6.object.to-string.js
1: import * as es6_object_toString from "/Users/areardon/code/react-beautiful-dnd/node_modules/core-js/library/modules/es6.object.to-string.js"; export default ( es6_object_toString && es6_object_toString['default'] ) || es6_object_toString;

@TrySound
Copy link
Contributor

Seems like the problem with size and missing exports is related to new rollup version and core-js.

@TrySound
Copy link
Contributor

Yep, it's regression in rollup

@alexreardon
Copy link
Collaborator Author

Thanks @TrySound. I will merge this PR as is and we can create a follow up issue to fix the umd build

@alexreardon alexreardon merged commit 82a387d into master Apr 17, 2018
@alexreardon alexreardon deleted the upgrading-deps branch April 17, 2018 11:01
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.

4 participants