connor4312 / cockatiel

🐦 A resilience and transient-fault-handling library that allows developers to express policies such as Backoff, Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback. Inspired by .NET Polly.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is this library tree-shakable?

rmeshksar opened this issue · comments

Hi,
Thanks for the great library.
I used this library for the first time in my Angular application and it works great.

In my example, I only import Policy and retry but noticed even in production build the whole library is in the generated code.

My question is that if this library is tree-shakable and if there is anything I need to do.

Thanks.

It's tree shakable, but due to the structure (which mirrors .NET Polly) policies don't get shaken out -- your code references Policy, which in turn is a factory for basically everything else. I want to tackle this for the 3.0 release. This might involve an API that looks something more like...

import { retry, handleType } from 'cockatiel';

const policy = retry(handleType(NetworkError)).attempts(3);