Reputation: 2344
Here's something I can't wrap my head around. I have these typescript files:
// app.ts
import {SomethingService} from "./something";
new SomethingService().yay();
-
// something.ts
export class SomethingService {
yay() {
alert('yay?');
}
}
-
// index.html
<html>
<head>
<script src="require.js"></script>
<script src="app.js"></script>
</head>
<body>
</body>
</html>
I then compile the TS with: tsc app.ts --module amd --outFile app.js
However, because of the import statement, app.ts is treated as a module and the actual code is never executed. The alert never pops up. How do I make sure the code in app.ts is executed?
Upvotes: 2
Views: 225
Reputation: 7621
So here it is you need to tell require.js to handle it.
<script data-main="app.js" src="require.js"></script>
Upvotes: 1