vuejs / vue-loader

📦 Webpack loader for Vue.js components
MIT License
4.99k stars 915 forks source link

使用swc-loader替换babel报错 #2057

Closed danielmlc closed 1 year ago

danielmlc commented 1 year ago

ERROR in ./src/App.vue?vue&type=template&id=7ba5bd90&ts=true (./node_modules/swc-loader/src/index.js!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/dist/index.js??ruleSet[1].rules[6].use[0]!./src/App.vue?vue&type=template&id=7ba5bd90&ts=true) Module build failed (from ./node_modules/swc-loader/src/index.js): Error: × Expected ',', got ':' ╭─[E:\project\webpack\swc-test\src\App.vue:6:1] 6 │ _hoisted_2 7 │ ] 8 │ 9 │ export function render(_ctx: any,_cache: any,$props: any,$setup: any,$data: any,$options: any) { · ─ 10 │ return (_openBlock(), _createElementBlock("div", _hoisted_1, _hoisted_3)) 11 │ } ╰────

Caused by: Syntax Error @ ./src/App.vue?vue&type=template&id=7ba5bd90&ts=true 1:0-245 1:0-245

demo地址: https://github.com/danielmlc/swc-test

haoqunjiang commented 1 year ago

需要配置 .swcrc 以支持 TypeScript 语法解析: https://swc.rs/blog/swc-1#typescript-support