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
+30-5Lines changed: 30 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,30 @@
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 helps you achieve reducing your JS bundles by renaming properties aren't exposed to the public.
7
+
A TypeScript custom transformer which reduces bundle size (with a help of other tools in your bundler - see below) by renaming properties aren't exposed to the public:
8
+
9
+
```typescript
10
+
function showMessage(opts: { message:string }):void {
_(note that terser/uglify/any other minifier [will rename `_internal_message` property](#how-to-minify-properties) to something like just `s`)_
8
31
9
32
You might find the approach pretty similar to how Google Closure Compiler with enabled advanced optimizations works,
10
33
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).
@@ -18,15 +41,17 @@ All you need to take all advantages from this tool are:
18
41
_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
42
_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._
20
43
21
-
## Caution!!!
44
+
## How safe renames are
45
+
46
+
As you might know that you have to pay for everything. The tool was tested on several packages and shows really good results (renames was 100% safe for them), but it doesn't mean that it's 100% safe for your project.
22
47
23
-
Before start using this transformer in the production, I strongly recommend you check that your code compiles successfully and all files has correct output.
48
+
If you rely a lot on duck typing (especially around public level/exports) - it _might_ break your code. But in any way to fix almost all issues I think you can just specify the correct type.
24
49
25
-
I would say **check the whole project file-by-file** and compare the input with the (expected) output.
50
+
I'd suggest everybody who wants to use it in production 1) run all tests you have 2) if it's possible - look at several (or all of them) compiled files in your project and see whether it's good or not.
26
51
27
52
I cannot guarantee you that the transformer covers all possible cases, but it has tests for the most popular ones, and if you catch a bug - please feel free to create an issue.
28
53
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.
54
+
Also, it might not work as expected with composite projects, because the project should contain an entry points you set in [options](#entrysourcefiles), but it might be in other sub-project. So I'd suggest to test it in non-composite project.
0 commit comments