Out of the box, Prepack does not fully model a browser or node.js environment: Prepack has no built-in knowledge of document or window . In fact, when prepacking code which references such properties, they will evaluate to undefined . You would have to insert a model of the relevant functionality at the beginning of the code you want to prepack.

The following helper functions aid in writing models.