I am currently working on a small project that requires me to write a JavaScript SDK. My initial plan was to create a TypeScript project and compile it into a single JavaScript file, allowing users of my SDK to easily inject that file into their web pages.
However, I recently discovered that if I use import
statements and try to compile the project into a single file, it only supports SystemJS.
So, my question is: How can I compile a TypeScript project into a single JS file that is usable in a browser?
By "usable in a browser," I mean that if I define a class called App
in TypeScript, I should be able to instantiate it in the developer console like this:
var x = new App();
I have been researching this issue for over an hour now, and everything I have found suggests that it may not be possible.
Edit: This does not provide a satisfactory answer to my question. As mentioned in the example, I need the functionality where if there is a class named App
in my TypeScript project, it should be accessible in the browser with the same name so that I can create a new instance using var x = new App()
in my dev console. (Or allow a user to do the same in their injected JS file after including my SDK file). This answer only explains how to generate an outfile in SystemJS.