JavaScript - join js files using tsc

9 points
Created by:

In this short article we would like to show how to join pure JavaScript files into singleĀ js file with tsc command.

Note: you can read this article too, to see how to compile *.ts file int single js file.

Simple steps:

1. prepare configuration for TypeScript compiler that will join our *.js files togather

There are avaialble two modules that let join files togatherĀ amd or systemĀ - in the below example we use amd one.

tsconfig.json file example:

	"version": "4.0.3",
	"compilerOptions": {
		"strict": true,
		"target": "es5",
		"module": "amd",  /* <----------------------- requred  */
		"composite": true,
		"declaration": true,
		"allowJs": true,  /* <----------------------- requred  */
		"sourceMap": true,  /* <--------------------- only for easier development  */
		"rootDir": "resources/",
		"outFile": "resources/merged.js"  /* <------- requred  */
	"files": [


  • files property contains list of all files that should be joined - should beĀ served in order we want keep.

2. runĀ compiler

It is necessary to runĀ tsc command from same directory, where is located tsconfig.json file.

Command example:



tsc -p path/to/tsconfig.json

Note: as result we should seeĀ src/main/webapp/resources/merged.js file with combined js files.

Native Advertising
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

ā¤ļøšŸ’» šŸ™‚