ts-browser icon indicating copy to clipboard operation
ts-browser copied to clipboard

"exports is not defined" error as soon as typescript file is declared as a module

Open fcamblor opened this issue 2 years ago • 0 comments

As soon as one of the typescript files are considered a module (as soon as you either use import or export keywords) we get an error stating :

exports is not defined

Case to reproduce :

  • Create a ts file with following content :
// module-test.ts
export const hello = "world";
  • Import it in your html file :
// index.html
<html>
<head>
    <script type="text/javascript" src="https://unpkg.com/ts-browser"></script>
    <script type="text/typescript" src="./module-test.ts"></script>
</head>
<body>
Demo
</body>
</html>

fcamblor avatar Nov 15 '22 11:11 fcamblor