babeljs - Làm thế nào để biên dịch typescript với babel 7 cli?
Cái này :
babel ./src/MyTypescript.ts --out-dir ./wwwroot/js/
không hoạt động (không có lỗi, chỉ hiển thị '0 biên dịch').
.babelrc chứa mọi thứ mà Babel 7 cần để biên dịch typescript với webpack babel loader: preset "@babel/typescript" và plugin "babel-plugin-transform-class-properties" (cặp này hoạt động với tôi trên babel 7 rc01 hiện tại).
Câu trả lời #1
Đây là một câu trả lời:
babel ./src/MyTypescript.ts --out-dir ./wwwroot/js/ --extensions '.ts,.js'
Câu trả lời #2
Câu trả lời được chọn không hiệu quả đối với tôi.
Tôi đã giải quyết với sự giúp đỡ của liên kết sau:
https://github.com/microsoft/TypeScript-Babel-Starter/blob/master/package.json
"build:js": "babel src --out-dir lib --extensions \".ts,.tsx\" --source-maps inline"Để thêm các phần mở rộng TS:
--extensions \".ts,.tsx\"