In Visual Studio 2015 Enterprise (Update 2 installed) I\'ve created a new TypeScript-Project TypeScriptHTMLApp1 from the Template (using default project settings). After that, I
You need to include requirejs or bundle your scripts with webpack. TypeScript provides the module syntax and compiles down into require
calls, but does not provide a runtime module loader. You must include that in your page for the scripts to work.
In the browser, make sure to provide the --module flag and specify the type of module you're using. This will typically be es6
for code you're running through webpack or amd
/umd
for older code using requirejs.
If you take a look at the TS compiler's output, you'll see that
import {foo} from './bar';
becomes
define(["require", "exports"], function (require, exports) {
"use strict";
});
but note that define
and the modules "require"
and "exports"
are not defined by the compiler.
If you're running in a node environment, the nodejs runtime provides the necessary functions for commonjs module loading.