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

Bundle size and build time improvements #715

Merged
merged 8 commits into from
Jul 1, 2020

Conversation

ptomato
Copy link
Collaborator

@ptomato ptomato commented Jul 1, 2020

This was the lowest-hanging fruit I could find for #710. Another benefit of smaller bundle size is reducing the time it takes to run the test262 tests! So while I was looking at that I made some further improvements to the build scripts.

The minified bundle size went from 177 kb to 135 kb, and the time it takes for the CI to run went from 9 to 7½ minutes.

ptomato added 8 commits June 30, 2020 17:21
This avoids having two copies of rollup in two separate node_modules
directories, makes it harder to forget to change something in all three
rollup config files, and allows making various improvements, such as:

- outputting playground.js directly to the website directory, rather
  than outputting it elsewhere and then copying it;
- running the replace() plugin on script.js, which decreases the size
  slightly by eliminating the debug code instead of skipping it, shaving
  about 10 seconds off of 'npm run test262'.
Instead of importing the whole of es-abstract, import only the abstract
operations that we actually use in the polyfill. This reduces the
minified bundle size by about a quarter. It also speeds up 'npm
run test262' by about thirty seconds on my machine.

See: #710
- mkdirp out/docs/assets already creates out/
- the npm scripts are run in subshells, so cd .. at the end does nothing
In 93e3403 I changed this due to a
warning from npm, but I had misunderstood how it works and also failed
to notice that it actually runs rollup twice whenever you build. Change
it back to what it was, for the time being.
These are duplicates of the polyfill's dependencies. They aren't used at
the top level.
We don't have these files anymore.
Loading mermaid from a CDN is going to be faster for people visiting the
page, as well as easier for us to maintain.
This cuts about a second off the build time, and I verified that it has
no effect on the built bundles whatsoever.

I think node-builtins was previously used to provide a custom shim for
util.inspect in the browser polyfill, but that does not seem to be
needed anywhere any longer.
@codecov
Copy link

codecov bot commented Jul 1, 2020

Codecov Report

Merging #715 into main will decrease coverage by 0.12%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #715      +/-   ##
==========================================
- Coverage   92.45%   92.33%   -0.13%     
==========================================
  Files          17       17              
  Lines        4720     4733      +13     
  Branches      746      743       -3     
==========================================
+ Hits         4364     4370       +6     
- Misses        351      360       +9     
+ Partials        5        3       -2     
Flag Coverage Δ
#test262 51.02% <100.00%> (+0.65%) ⬆️
#tests 87.11% <100.00%> (+0.03%) ⬆️
Impacted Files Coverage Δ
polyfill/lib/ecmascript.mjs 95.39% <100.00%> (+0.04%) ⬆️
polyfill/lib/absolute.mjs 96.41% <0.00%> (-0.45%) ⬇️
polyfill/lib/yearmonth.mjs 94.60% <0.00%> (-0.42%) ⬇️
polyfill/lib/timezone.mjs 93.25% <0.00%> (-0.40%) ⬇️
polyfill/lib/date.mjs 90.90% <0.00%> (-0.35%) ⬇️
polyfill/lib/time.mjs 96.61% <0.00%> (-0.34%) ⬇️
polyfill/lib/calendar.mjs 64.92% <0.00%> (-0.31%) ⬇️
polyfill/lib/duration.mjs 97.02% <0.00%> (-0.25%) ⬇️
polyfill/lib/datetime.mjs 92.16% <0.00%> (-0.17%) ⬇️
polyfill/lib/intrinsicclass.mjs 59.25% <0.00%> (ø)
... and 1 more

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 252c68e...60eca2d. Read the comment docs.

Copy link
Member

@ryzokuken ryzokuken left a comment

Choose a reason for hiding this comment

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

I'm not the biggest rollup/babel expert, but all commits LGTM.

@ryzokuken ryzokuken merged commit 3d24753 into main Jul 1, 2020
@ryzokuken ryzokuken deleted the bundle-size-and-build-time-improvements branch July 1, 2020 17:58
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Jul 8, 2020
tc39#715 broke Test262 tests (specifically the ability to
`import * from 'es-abstract'), and I couldn't figure out how
to import individual es-abstract js functions from the PoC
TypeScript code, so I gave up and hacked up the three es-abstract
methods (ToString, ToObject, and ToInteger) that the PoC uses.
A real JS implementation will simply depend on ecmascript.js, so it
wasn't worth doing a real implementation. I apologize for how bad
this placeholder code is. ;-(
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Jul 8, 2020
- Convert all conversion methods to use new toXxx naming convention
- Fix Test262 tests broken by build changes in tc39#715
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Aug 1, 2020
- Convert all conversion methods to use new toXxx naming convention
- Fix Test262 tests broken by build changes in tc39#715
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Aug 10, 2020
- Convert all conversion methods to use new toXxx naming convention
- Fix Test262 tests broken by build changes in tc39#715
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Aug 31, 2020
- Convert all conversion methods to use new toXxx naming convention
- Fix Test262 tests broken by build changes in tc39#715
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Sep 14, 2020
- Convert all conversion methods to use new toXxx naming convention
- Fix Test262 tests broken by build changes in tc39#715
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Sep 14, 2020
- Convert all conversion methods to use new toXxx naming convention
- Fix Test262 tests broken by build changes in tc39#715
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Sep 17, 2020
- Convert all conversion methods to use new toXxx naming convention
- Fix Test262 tests broken by build changes in tc39#715
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Sep 18, 2020
- Convert all conversion methods to use new toXxx naming convention
- Fix Test262 tests broken by build changes in tc39#715
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Sep 26, 2020
- Convert all conversion methods to use new toXxx naming convention
- Fix Test262 tests broken by build changes in tc39#715
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Oct 7, 2020
- Convert all conversion methods to use new toXxx naming convention
- Fix Test262 tests broken by build changes in tc39#715
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Oct 11, 2020
- Convert all conversion methods to use new toXxx naming convention
- Fix Test262 tests broken by build changes in tc39#715
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Oct 12, 2020
- Convert all conversion methods to use new toXxx naming convention
- Fix Test262 tests broken by build changes in tc39#715
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Oct 16, 2020
- Convert all conversion methods to use new toXxx naming convention
- Fix Test262 tests broken by build changes in tc39#715
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Oct 16, 2020
- Convert all conversion methods to use new toXxx naming convention
- Fix Test262 tests broken by build changes in tc39#715
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Oct 17, 2020
- Convert all conversion methods to use new toXxx naming convention
- Fix Test262 tests broken by build changes in tc39#715
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Oct 19, 2020
- Convert all conversion methods to use new toXxx naming convention
- Fix Test262 tests broken by build changes in tc39#715
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Oct 21, 2020
- Convert all conversion methods to use new toXxx naming convention
- Fix Test262 tests broken by build changes in tc39#715
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