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

[enhance] Small bundle reduction by using typescript 'declare' #177

Merged
merged 1 commit into from
Nov 10, 2019

Conversation

ntucker
Copy link
Collaborator

@ntucker ntucker commented Nov 10, 2019

Motivation

TypeScript 3.7 introduced a new 'declare' property modifier, which enables declaring property types without setting the default to void 0 in javascript. This is useful when they are actually set in the constructor. The end result is several lines removed from output that don't need to be executed.

Solution

We also start using optional chaining in tests. We need the latest prettier to work with this new syntax.

Optional chaining is not used in the main code as it results in extra output bloat.

Before

src/index.ts → dist/index.umd.min.js...
┌────────────────────────────────────────┐
│ │
│ Destination: dist/index.umd.min.js │
│ Bundle Size: 21.53 KB │
│ Minified Size: 21.43 KB │
│ Gzipped Size: 6.86 KB │
│ │
└────────────────────────────────────────┘

After

src/index.ts → dist/index.umd.min.js...
┌────────────────────────────────────────┐
│ │
│ Destination: dist/index.umd.min.js │
│ Bundle Size: 21 KB │
│ Minified Size: 20.9 KB │
│ Gzipped Size: 6.76 KB │
│ │
└────────────────────────────────────────┘

@ntucker ntucker merged commit e7c362e into master Nov 10, 2019
@ntucker ntucker deleted the typescript branch November 10, 2019 00:09
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.

None yet

1 participant