As you can see in the new bundle, CarService is no longer included. (Just search for “BMW”).

Perhaps the biggest benefit of this is not actually “Tree shaking”. It's likely going to be more impactful that this allows us to produce minified ES6 bundles.

This benefit can be seen in TypeScript projects since transpiled ES5 code is usually more verbose than the ES6 counterpart. I discus this more in one of my other articles.

One consideration here is of course that you now need your supported browsers to support ES6.
In cases where you support older browsers, you can just transpile your bundle down to ES5, and still keep the mentioned "dead code removal" benefits.

Thoughts on Tree shaking

My view is that Tree shaking is a brilliant approach, but I think the practical benefit is often exaggerated. Not because of how Tree shaking works, but because code is often not structured for ideal Tree shaking.

More broadly I also want to point out that Tree shaking is only effective if your modules export multiple statements. Personally I don't usually structure my modules with multiple exports since I think it often violates single responsibility principles.

One exception to this though is third party libraries. It might be practical to publish libraries as combined bundles with multiple exports. You see this format in Angular these days with the flat esm bundle format.