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

chore: type checking in one place makes bundle smaller #843

Merged
merged 8 commits into from
Oct 24, 2023

Conversation

pauldambra
Copy link
Member

@pauldambra pauldambra commented Oct 22, 2023

#ShowerThoughts

We have ~60 instances of type checks which might be smaller in the final bundle if they all point at a function instead of doing the work...

Let's find out ......

Looks like array.js is 1% smaller

@github-actions
Copy link

github-actions bot commented Oct 22, 2023

Size Change: -2.55 kB (0%)

Total Size: 723 kB

Filename Size Change
dist/array.full.js 176 kB -688 B (0%)
dist/array.js 118 kB -720 B (-1%)
dist/es.js 118 kB -704 B (-1%)
dist/module.js 118 kB -704 B (-1%)
dist/recorder-v2.js 95.1 kB +90 B (0%)
dist/recorder.js 58.4 kB +90 B (0%)
dist/surveys.js 39.6 kB +85 B (0%)

compressed-size-action

@pauldambra pauldambra marked this pull request as draft October 22, 2023 12:15
@pauldambra pauldambra marked this pull request as ready for review October 23, 2023 08:26
@pauldambra pauldambra changed the title chore: does type checking in one place make bundle smaller? chore: type checking in one place makes bundle smaller Oct 23, 2023
Copy link
Contributor

@daibhin daibhin left a comment

Choose a reason for hiding this comment

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

Looks good! Is there an easy linting rule that could be added so you don't have to come back and do this again?

@pauldambra pauldambra requested a review from daibhin October 23, 2023 11:26
Copy link
Collaborator

@benjackwhite benjackwhite left a comment

Choose a reason for hiding this comment

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

I like it a lot. (Echo David's comment)

@pauldambra pauldambra merged commit 07766f8 into master Oct 24, 2023
11 checks passed
@pauldambra pauldambra deleted the chore/smaller-bundle-experiment branch October 24, 2023 11:01
BinaryExpression: function (node) {
// Check for `toString.call(obj) == '[object Boolean]'`
if (
(node.operator === '==' || node.operator === '===') &&
Copy link
Contributor

Choose a reason for hiding this comment

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

So meta 😂

Copy link
Contributor

@daibhin daibhin left a comment

Choose a reason for hiding this comment

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

Amazing!

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.

3 participants