-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Why is file size so big? #3971
Comments
You are importing everything in rxjs surface api via https://github.com/bcherny/undux/blob/master/src/index.ts#L1, If codes are targeting v5 import each individual via corresponding subimport, if it's v6 follow guide for optimization. https://github.com/ReactiveX/rxjs/blob/master/doc/pipeable-operators.md#build-and-treeshaking |
No, I'm only importing the type. It's compiled away by TSC before it reaches Webpack. Confirmed by avoiding the wildcard import.
Those instructions only cover |
You have incorrect understanding of subpath import.
is nothing more than
ends up importing all surface as same as before. Try create simple test.ts as below
and transpile it: you'll get
CJS will import whole rxjs still. contray, if you import subpath
transpiliation limits import path
|
in short, impot path is bit different between v5 and v6, but do not import everything is key. |
also, this is very true and if you only use types, it should have zero actual codes. But also, you have specified package as peerdep - how do you actually confirm it's type only, especially you mentioned you do call |
@kwonoj Without
And
Also this?
And to be clear, my actual import is in typed-rx-emitter:
|
above snippet written through v5, as your package peerdep specifies rx >=5 is allowed. As mentioned |
Figured out my issue - in TS, you have to compile to tl;dr- With
That means if my package That seems wrong. Since file size is An alternative solution is to fix RxJS6's re-exports in compat mode, so that even if you or one of your dependencies compiled The results seem to be clear: Before patch
After patch
That said, I'm not familiar with RxJS's codebase, and this kind of module and bundling stuff can be tricky. Please let me know if I missed something. |
I'm using RxJS6 in Undux, via typed-rx-emitter. I use it by importing
Observable
, and callingObservable.create
. I don't use any other Rx methods.Bundling Undux (+typed-rx-emitter, +rxjs) in as part of undux-todomvc, I see all sorts of things included in the bundle that I'm not using. Eg:
All in all, that's ~80kb (unmangled). Even after running the code through Uglify's tree shaker, these are included. Are they core parts of
Rx.Observable.create
? Is there a way to remove them? Am I doing something wrong when bundling?Repro:
Generated bundle.js (after Uglify)
Uglify options:
The text was updated successfully, but these errors were encountered: