我想将我的TypeScript项目编译成包含 JQuery的单个文件,这样我的HTML中就有一个<script src="mystuff.js"></script>
标记。 tsc
可以这样做吗?或者我是否需要诉诸webpack或其他类似的东西?
我的tsconfig.json
看起来像这样:
{
"compilerOptions": {
"allowJs": true,
"declaration": false,
"jsx": "react",
"moduleResolution": "node",
"module": "amd",
"noImplicitAny": false,
"noImplicitThis": false,
"noUnusedLocals": true,
"noUnusedParameters": false,
"strict": false,
"outFile": "chooser.js",
"preserveConstEnums": true,
"pretty": true,
"removeComments": true,
"sourceMap": true,
"sourceRoot": "./ts/",
"target": "es2017"
},
"include": [
"ts/*.ts",
"ts/*.tsx",
"ts/**/*.ts",
"ts/**/*.tsx"
],
"exclude": [
"typings"
]
}
我唯一的TypeScript文件现在看起来像这样:
import * as $ from 'jquery';
export function getData() {
return new Promise((resolve, reject) => {
$.get('/salaries.csv', {
onComplete: (result) => {
console.log('result', result);
}
})
})
}