Posts Tagged ‘Bundle Size’

OOPs! No Tree Shaking!

Monday, August 19th, 2024

It’s good practice to validate data coming into your program, whether that be from a user, the network, disk, or anywhere else. It’s a first line of defense to prevent bad data from getting into your program and causing problems later, and provides early signals of mismatched expectations or changes in the data format over time.

From JavaScript, JSON is one of the more convenient data serialization formats. Consequently, you need a way to validate that data as well. There are many ways to do this, both declarative and imperative. Declarative, mostly in the form of JSON Schema, holds a lot of appeal to me, but it has some drawbacks of its own.

For my use case, I care a lot about code size. As much as possible, if I am using a library and it has functionality I am not using, I would like that code stripped out of my program by the bundler.

(more…)