You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-17Lines changed: 20 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,12 +4,19 @@
4
4
[![npm version][npm-version-img]][npm-link]
5
5
[![Downloads][npm-downloads-img]][npm-link]
6
6
7
-
A TypeScript custom transformer which renames all properties if they aren't exported from entry point (in any way) and imported from external package.
7
+
A TypeScript custom transformer which helps you achieve reducing your JS bundles by renaming properties aren't exposed to the public.
8
8
9
-
It might help you better minify your bundles with any existing minifier/uglify tool which supports properties mangling.
9
+
You might find the approach pretty similar to how Google Closure Compiler with enabled advanced optimizations works,
10
+
but you don't need to refactor your project a lot to make it works for Google Closure Compiler (setting up [tsickle](https://github.com/angular/tsickle) might be hard as well).
10
11
11
-
This is the next generation of [ts-transformer-minify-privates](https://github.com/timocov/ts-transformer-minify-privates) (which allows you rename the only private class' members),
12
-
which uses some approaches from [dts-bundle-generator](https://github.com/timocov/dts-bundle-generator) to detect whether some property is accessible via entry points somehow.
12
+
All you need to take all advantages from this tool are:
13
+
14
+
1.[Install it](#installation)
15
+
1.[Setup your compiler to use it](#how-to-use-the-custom-transformer)
16
+
1.[Setup the tool you use to minify/uglify to mangle properties](#how-to-minify-properties)
17
+
18
+
_This is the next generation of [ts-transformer-minify-privates](https://github.com/timocov/ts-transformer-minify-privates) (which allows you rename the only private class' members),_
19
+
_which uses some approaches from [dts-bundle-generator](https://github.com/timocov/dts-bundle-generator) to detect whether some property is accessible via entry points somehow._
13
20
14
21
## Caution!!!
15
22
@@ -21,6 +28,15 @@ I cannot guarantee you that the transformer covers all possible cases, but it ha
21
28
22
29
Also, it might not work as expected with composite projects, because the project should contain an entry points you set in options, but it might be in other sub-project.
23
30
31
+
## How it works
32
+
33
+
For every property the tool tries to determine whether a property is accessible from entry points you specified in the [options](#entrysourcefiles).
34
+
35
+
The property is "accessible from entry point" if the type where this property is declared (including all base classes/interfaces) is directly exported or accessible via entry point
36
+
(this approach and algorithms are taken from <https://github.com/timocov/dts-bundle-generator>).
37
+
38
+
If you rely on duck typing a lot in your project - the tool **MIGHT NOT** and quite possible **WILL NOT** work properly, especially it can't detect if the property is exported (because it uses the only explicit "inheritance/usage tree").
39
+
24
40
## Example
25
41
26
42
Let's say we have the following source code in entry point:
@@ -46,8 +62,6 @@ export function getOptions(fooBar: number): Options {
46
62
After applying this transformer you'll get the next result:
@@ -133,15 +145,6 @@ More examples you can see [in test-cases folder](https://github.com/timocov/ts-t
133
145
1. Install the package `npm i -D ts-transformer-properties-rename`
134
146
1. Add transformer with [one of possible ways](#how-to-use-the-custom-transformer)
135
147
136
-
## How it works
137
-
138
-
For every property the tool tries to understand whether a property is accessible from entry points you specified in the [options](#options).
139
-
140
-
The property is "accessible from entry point" if the type where this property is declared (including all base classes/interfaces) is directly exported or accessible via entry point
141
-
(this approach and algorithms are taken from <https://github.com/timocov/dts-bundle-generator>).
142
-
143
-
If you use duck typing a lot in your project - the tool **WILL NOT work properly**, especially it can't detect if the property is exported (because it uses the only inheritance tree).
0 commit comments