-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Fix minified bundle #3261
Fix minified bundle #3261
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix is to use "entry" and add @babel/polyfill to gulp's browserify step. Increases the minified bundle's size about 150 kb (~10%). This wouldn't affect anyone whose packing things themselves though.
entry
is not only a fix it does also improve the way babel does add those imports and this should save some lines. An increase of 10% is in my view of point to much and should already show us that we do add to much stuff.
I've used the babel runtime and transform runtime plugin by side of the preset-env
to be sure the required regenerator runtime is existing for each bundle and also to have just one absolute @babel/runtime
package.
Could you elaborate on why exactly the usage
or entry
useBuiltIns
options do make the difference as mentioned in the PR desc? As I know and only if babel does transpile our packages correctly should this not affect us in this way. The only difference is where exactly those imports are located (globally in the bundle or for each file).
Was just looking at the babel docs and honestly I don't know if useBuiltIns is the right option if the polyfill is being injected....
Yes, it isn't the correct thing. The goal would be to only use the useBuiltIns
options and the corejs polyfills. The @babel/polyfill
package you have added is already marked as deprecated by babel and I think we shouldn't rely on deprecated packages for this fix.
The clearest description I could find for this was in babel polyfill docs. But before I also tried many combinations of runtime plugins in the preset env block and could not get both tests passing. Maybe there's a way with
Please feel free to experiment with this! If you can get rid of the polyfill that would be incredible. The only thing I'd ask is that the tests remain as they are - they trigger the two errors we've seen.
Agree, this is not a fix. It's a patch to stop something crashing. Over desktop the difference in loading the min over CDN with another 10% should be +25ms and it will not affect anyone bundling by themselves either. Lastly - we agree the way forward is with rollup. If gulp will be ripped out within 1 month and the tests here are correct, then getting the babel setting perfect might be less important. |
@cgewecke As already commented did I fix the Edit: |
@nivida Ah great!! Thanks so much for figuring that out. |
Co-Authored-By: Samuel Furter <nivida@users.noreply.github.com>
…ulp build pipeline
…ne because the babel transform runtime plugins brings up a bunch of other errors
@nivida Couple additional notes:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I re-reviewed this, and it looks really good now :)
Phew, what a detective work. Great!! 😄 |
Description
NB: This PR targets the buildsize checker PR #3260, prerequisite for merging here
The bundle entry point is corrupted due to fix proposed in #3155 & implemented in #3206
There are two settings for the babel presets and in web3's case, picking either breaks the build in a different way.
The fix is to use "entry" and add
@babel/polyfill
to gulp's browserify step. Increases the minified bundle's size about 150 kb (~10%). This wouldn't affect anyone whose packing things themselves though.PR adds
tests for the "require not defined" case (git repo and published bundles). The "runtime" error is already caught by the browser tests.
an E2E validation which models the CDN use-case. It publishes a simple website which uses the bundle to a random url at surge.sh. This site uses Web3 to query the latest block from mainnet over Infura. An example from this PR's CI run is at:
sudden-playground.surge.sh
(Sometimes surge.sh fails with an auth error because it's generated a name which is already taken or something. The tests will pass though - the surge check is just meant to be a convenience.)
The commits are sequenced with initially failing tests so their correctness can be checked:
Fixes #3256
Type of change
Checklist:
npm run dtslint
with success and extended the tests and types if necessary.npm run test:unit
with success and extended the tests if necessary.npm run build-all
and tested the resulting file/'s fromdist
folder in a browser.CHANGELOG.md
file in the root folder.