Multiple files making up Type Script project

后端 未结 3 1176
不知归路
不知归路 2020-12-31 00:15

Recently I have been working with TypeScript and everything has been fine and I really, really like it.. Makes JavaScript workable again! :)

we have tried to follow

3条回答
  •  囚心锁ツ
    2020-12-31 01:04

    You have two options here, either commonjs, or AMD (asynchronous module loading).
    Using commonjs, you will need to place a

    
    

    for each separate javascript file in your project in your html page.
    Obviously this can become very tedious, especially if you have hundreds of files in your project.
    Alternatively, as Steve Fenton pointed out, you can use the --out parameter to compile various files into a single file, and then reference just this single file in your html page.

    Using AMD is the third option - where you only need to include one script tag in your html page, and AMD takes care of references.
    Have a look at my blog on how to get this working : http://blorkfish.wordpress.com/2012/10/23/typescript-organizing-your-code-with-amd-modules-and-require-js/

提交回复
热议问题