Laura10101 / contractor-tax-calculator

0 stars 2 forks source link

"Module" not defined when loading config app in browser #211

Closed Laura10101 closed 10 months ago

Laura10101 commented 10 months ago

When loading the config app in any browser, a JavaScript error is thrown: '"module" is undefined'.

Laura10101 commented 10 months ago

This is caused by the module exports and the require statements that were added to the script files for the config app to enable automated testing. The issue was resolved by wrapping the require and export statements in code to check whether "module" is defined. Since this places the require statements into a block, the constants that functions and objects are imported into are not available outside of the block. The modules are therefore loaded into a constant, and the relevant bits of each module are then loaded into global variables to allow for a consistent experience in automated testing and within the browser.