Webpack bundling enhancements

Various enhancements that didn't make it into the the original PR (#1992) / original  commit (66f796c00705f5f7eeaba46626a6c5e8d4e99a7e).
'require' is not defined.