Move `global` module require into `buildTemplate` to avoid requiring it for common cases.