Webpack change window globale object scope

334 views Asked by At

I am importing the npm module JSEncrypt in my module to encrypt data. JSEncrypt has window exported global object window.Base64.

I am using webpack to bundle all modules. After bundling I run the code on the browser I can write on console window.Base64 to get the value of this object.

For security and compatibility reasons I would like to prevent that by changing window.Base64 to local scope instead of window.

Is that possible through webpack?

1

There are 1 answers

0
Filip Dupanović On

You can look at the various options available for shimming modules, specifically the exports-loader.

This will bind the global to a module scope and it won't be overwriteable outside of Webpack's runtime.