4

I have a typescript library that uses 3rd party imports. I want to compile the typescript to vanilla js. However when trying that, the compiled javascript code has the keyword "exports". If I am trying to import that in a legacy angularjs application, it does not know what an exports is. Is there a way to compile the typescript into pure vanilla js without any dependencies?

Tried using webpack.

random_user_name
  • 25,694
  • 7
  • 76
  • 115
vadugs
  • 71
  • 1
  • 4
  • This may be to do with the target you're setting on TypeScript. If you set it to ES6 or later, it will produce code with `exports` – Richard Mar 22 '19 at 18:15
  • IMO it sounds like you're confused about the module patterns people use is JS. I'd suggest reviewing: https://stackoverflow.com/questions/16521471/relation-between-commonjs-amd-and-requirejs – Steven Stark Mar 22 '19 at 18:15
  • This is not what TypeScript compiler is for. To compile modular javascript into something without exports, you have to use a bundler like [browserify](http://browserify.org/), [webpack](https://webpack.js.org/) or [rollup](https://rollupjs.org/guide/en) – artem Mar 22 '19 at 19:53

0 Answers0