and*_*oss 4 javascript typescript yarnpkg
如何在 Yarn 管理的项目中将 TypeScript 代码转译为 JavaScript?
我需要 Javascript 代码才能与其他编译器(例如 GraalVM)一起运行它并研究性能。
小智 9
您可以通过向您的package.json.
{
"name": "my-package",
"scripts": {
"build": "tsc -p .",
}
}
Run Code Online (Sandbox Code Playgroud)
代替。tsconfig.json 文件的路径,例如包含以下行。
{
"compilerOptions": {
"target": "ES2019", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"outDir": "./dist", /* Redirect output structure to the directory. */
"strict": true, /* Enable all strict type-checking options. */
"strictNullChecks": true, /* Enable strict null checks. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
Run Code Online (Sandbox Code Playgroud)
跑步yarn run build。
转译后的 JavaScript 文件将位于该./dist目录中。
| 归档时间: |
|
| 查看次数: |
11821 次 |
| 最近记录: |