Having a simple Typescript project I'm using Gulp to build individual JS files from my TS files (I'm doing this as I have multiple HTML files which are to remain separate).
var tsResult = gulp.src('./src/ts/**/*.ts')
.pipe(ts(tsProject));
return merge([ // Merge the two output streams, so this task is finished when the IO of both operations are done.
tsResult.dts.pipe(gulp.dest('release/definitions')),
tsResult.js.pipe(gulp.dest('release/js'))
]);
So inside my HTML I'll have something like -
<script src="./js/myTSfileTranspiledToJS.js"></script>
Lets say that the TS file had a reference to a 3rd party code base such as jQuery. The code builds and deploys fine with no errors, but when I go to call a method in my TS/JS that contains the jQuery it fails. This is because when runs it has no jQuery code.
Now I can include the jQuery code using a script tag -
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
but I'd rather not. Is there any way of including/bundling the 3rd party code into the transpiled JS files.
EDIT
To be clear - I'm looking to have a Typescript project that generates some JS files and anything that those JS files depend on should be bundled with them without the need to load them separately. So if A.js requires B.js, then I want the build to see that and include B.js with A.js to save me adding B.js to some html file. As an answer below has suggested - Broswerify, but I've not figured that out yet in my setup.