0

I have been digging around trying to find the answer to this:

How can I debug modular TypeScript with source maps?

TypeScript generating wrong JS in Release Mode

Typescript AMD Modules in Visual Studio

but so far no luck. I have a Visual Studio 2015 Angular project with TypeScript. I am trying to get debugging working. My TypeScript files are coded with CommonJS. When I run the app and try and debug it errors saying "exports is not defined." When I change the app to use AMD it runs in IE but not in chrome as the js gets created like this:

define(["require", "exports"], function (require, exports) {
function sayHello() {
    alert("I am here");
}
exports.sayHello = sayHello;
function yo() {
    alert("yo");
}
exports.yo = yo;
});
//# sourceMappingURL=TestMessage.js.map 

and Chrome now says "define" is not defined. If I leave the mode as CommonJS both Chrome and IE error saying "exports is not defined." Seems like I am missing something here. Any ideas what? Here is why TS file:

export function sayHello() {
alert("I am here");
}

export function yo() {
alert("yo");
}

1 Answer 1

2

Commonjs is a module system used mainly by nodejs. AMD is intended for the browser.

You can use what ever you like, but each requires a library to make it work in the browser.

For commonjs you can use webpack browserify or systemjs.

For AMD you can use requirejs or systemjs.

Sign up to request clarification or add additional context in comments.

2 Comments

So we are using webpack but here is the issue I am trying to over come. Webpack takes all my TS and puts it into one file. To easy Dev debugging I am trying to keep them all in different files. However, I can't seem to get webpack (awesome-typescript-loader) to keep all the files separate. This probably goes in the face of webpack.
We are actually using webpack-stream. And to do what I was after I found vinyl-named that lets me stream out all the individual files. So I think I have this now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.