-
Notifications
You must be signed in to change notification settings - Fork 382
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
WIP: Remove EventEmitter from roslib.js bundle #344
Conversation
The output roslib.js works, but this breaks
|
0e210a7
to
6ad4656
Compare
You are right, I broke the tests. I've now fixed them. I've to check webpack next to make sure I'm not breaking anybody's workflow. |
It works now, but I'm not sure this should be done. Removing EventEmitter from the bundle makes ROSLIB smaller, but you still have to obtain EventEmitter, so the overall application size is probably about the same and it's a separate HTTP request to a separate host rather than multiplexed. In my quick testing, this PR + going to a CDN for EventEmitter doubles the load time of the ROSLIB stack compared to using bundled EventEmitter on develop. A better change might be to stop instructing people to load EventEmitter from CDN (or anywhere), because it's no longer required and is just slowing things down. Bundling the dependency is more convenient and faster for most users, I think. |
So the problem I have is that I'm also using EventEmitter in my own code and so the library will have to be loaded twice. This is wasted data. With this PR I'm only having to download one copy. This is how it used to work before 5d13337. |
f5209d3
to
f12a1db
Compare
cd7040e
to
c16db14
Compare
Converting this PR to a draft, as the title indicates it's WIP. |
I'm not sure why, but EventEmitter is included within roslib.js. It should be a dependency according to all the readmes. This change excludes it from the bundle. | name | roslib.js | roslib.min.js | |------|-----------|---------------| | old | 132K | 53K | | new | 107K | 42K |
c16db14
to
1b948c8
Compare
@EzraBrooks I see you marked this as a draft. But what do you think of this PR? I think this is a relevant PR to consider, when we want to improve library quality. I do know @Rayman, so I know he is open to discuss/explain when needed. |
I definitely agree with this from a philosophical perspective, but won't it break the CDN-served scripts? Might require a major version bump. |
@MatthijsBurgh in this PR #615 you removed loading eventemitter from the CDN. This means the bundled eventemitter is now used. So this PR will break the examples. Originally this package was designed that you first load eventemitter2, then roslib in a script tag. This makes both files easily cachable and small. |
Lets include this in v2. |
This will indeed require adding back loading the eventemitter CDN in the examples |
Finally going to get this change in via #688 🙂 |
I'm not sure why, but EventEmitter is included within roslib.js. It
should be a dependency according to all the readmes. This change excludes it from the bundle.
Bundle size analysis here:
https://roslibjs-bundle-size-example.netlify.com