17

Can any Typescript experts clarify when and why you would choose AMD vs Common JS for module creation when using Typescript?

2 Answers 2

19

AMD is used in the browser (e.g RequireJS) : reason is it allows parallel download of files as network latency is a major bottleneck.

CommonJS is used in the server (e.g. nodejs) where files can be read from disk upfront, but you don't want to read a file till you try to use the code it contains.

Here is a video on the subject that further explains this : http://www.youtube.com/watch?v=KDrWLMUY0R0

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

Comments

9

Are you using require.js? Use AMD

Are you using node.js? Use CommonJS

Don't know what those are? Not using either of them? Don't use external modules.

1 Comment

This would be more helpful for beginners if a bit more explanation were included, especially along for the "Don't use external modules" advice.

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.