TypeScript: Avoid require statements in compiled JavaScript
问题 In my TypeScript code I am using a third-party library called bunyan like so: private logger: bunyan.Logger = bunyan.createLogger({name: "MyClass"}); Because TypeScript cannot resolve the variable bunyan , I do this to make the TypeScript compiler work: import * as bunyan from "bunyan"; Unfortunately this causes the following JavaScript output: var bunyan = require("bunyan"); The require statement will not work in the browser (when not using a requirejs implementation), so I will receive: