I have been looking at using TypeScript and Browserify together. What I can't understand is that they both use require. TS uses require to require other TS modules. Browserify uses requires to find other js files.
So the thing I can't understand here is that I would have to pass it through 2 compilation stages. 1 stage would compile TS to JS (with Browserfiy requires still left in). And 2nd stage would convert JS (with Browserify) to 1 big file reading for production.
How do these compilers above, know the difference between a require for Browserify and a require for TypeScript ?
TypeScript compiler (tsc) parses the following require
syntax:
import m = require("mod");
whereas normally you just write
var m = require("mod");
The later syntax is not checked by tsc more in-depth - it's just a simple assignment for tsc. The former one is checked by tsc to verify that mod
is a module written in TypeScript (example)