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

Feature/webpack optimizations #833

Merged
merged 2 commits into from
Jun 14, 2021
Merged

Conversation

oshi97
Copy link
Contributor

@oshi97 oshi97 commented Jun 14, 2021

See here for a comparison of webpack devtool options
https://webpack.js.org/configuration/devtool/

'source-map' is listed as one of the slowest options
for build, and is recommended for production builds
that want high quality source maps.
Changing this to 'eval' shaves off 0.5s from the build time,
while still providing a source map in dev mode.

J=SLAP-1373
TEST=manual

see ~0.5s shaved off the webpack build time
see that I get source maps in dev mode, and can
add a console log to a formatter and clicking on
the console.log's line number will take me to the
correct source line in dev tools
This commit separates bundle.js into the polyfill-free
bundle.js and polyfilled bundle-legacy.js. Both still
run through the babel loader, because the esbuild minifier
is set to target es5, and does not let you minify some
bundles to es5 and some bundles to newer javascript.

The type="module" and nomodule script loading pattern is used
to dynamically load the correct bundle. This is the pattern we
use for determining whether to use answers-modern or answers
assets. This shrinks bundle.js from 443KB to 313KB in prod mode
(and from 1.3MB to 705KB in dev mode). In prod mode the page speed
went from 50 -> 56, and in dev mode the page speed lighthouse scores
went from 36 -> 48.

J=SLAP-1373
TEST=manual

see ~0.7s build speed improvements on yanswers and answers-atlanticsearch
when I remove the core-js import from entry.js
this build speedup doesn't show up for the test-site for some reason, though
investigated for a while but could not figure out why
I figured that yanswers and another random repo would be better benchmarks, though
the test-site's build speed was also not hurt at all by this change

see that the production modern bundle shrinks from 443KB to 313KB after removing
polyfills

smoke test that full page map on ie11 (browserstack), firefox, safari, chrome, and
galaxy s6 chrome (browserstack)

see that bundle.js is inlined properly, and only the modern one is inlined
@oshi97 oshi97 merged commit 382cac1 into develop Jun 14, 2021
@oshi97 oshi97 deleted the feature/webpack-optimizations branch June 14, 2021 17:20
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.001%) to 5.525% when pulling 5e08a2a on feature/webpack-optimizations into 3778264 on develop.

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.

2 participants