To fix the ‘Uncaught ReferenceError: exports is not defined’ error in files generated with TypeScript, we should remove the "type": "module" option from tsconfig.json.
For instance, if we have
{
//...
"type": "module"
//...
}
in tsconfig.json then we should remove it so that the TypeScript compiler will transpile the code into something that doesn’t have export and import in the generated files.