-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
perf(emit): decrease emitted code #169
Conversation
…d by not always using get/set for properties
@@ -4,6 +4,8 @@ import { KeyCounter } from './keyCounter'; | |||
export type PossibleDeclaration = ts.InterfaceDeclaration | ts.ClassDeclaration | ts.TypeAliasDeclaration; | |||
|
|||
export class FactoryUniqueName { | |||
private static AnonymousIdentifierText: string = '*'; |
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.
Can we put these values with the other one? Do you think it's a good idea to keep all these "reduced" identifier names in one place?
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.
done!
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.
Just one small thing :)
…e mockProperty file so that it reflects its new purpose
@uittorio I've also renamed mockProperty.ts to reflect the new purpose |
This PR decreate emitted code by using minification techniques and by not always using get/set for properties. The emitted code is reduced in average by 35%.
Use case is mocking the entire
@types/babel-types
module:Current version
626583 characters
ADD assign properties by always using element access (
m["prop"] = 0
)447669 characters
ADD reduced string identifier for factory (
create__NAME__mock
to@NAME
)434162 characters
ADD element access only when signature is there, otherwise object literal (
m = { "prop": 0 }
)428726 characters
ADD
undefined -> void 0
and don't assignvoid 0
properties408600
ADD
false -> !1
andtrue -> !0
404922
I've also found that by reducing Repository/Merge/Extension import variable name and methods name to 1-2 characters we could even drop that number to 35k~ but I think that needs more investigation.