Why can not find the source vue component file in browser developer tool if vue component is written in typescript?

I am using vue2, my build tool is [email protected]. In order to debug the vue source component file easily, I add a configuration in output.devtoolModuleFilenameTemplate, the code is as below:

const resPath = path.normalize(info.resourcePath)
const isVue = resPath.match(/.vue$/)
const isGenerated = info.allLoaders
const isTypeScript = info.allLoaders && info.allLoaders.includes('ts-loader')

const generated = `webpack-generated:///${resPath}?${info.hash}`
const vuesource = `vue-source:///${resPath}`

if (isVue) {
    if (!isGenerated || isTypeScript) {
        return vuesource
    } else {
        return generated
    }
} else {
    return vuesource
}

The devtool config is devtool: 'source-map'.

Now what’s weird is, if the vue component is written in pure javascript, then I can find the source file easily, refer to below:

When click the above highlight part, show the content as below:

However, if the vue component is wrtten in typescript, which means has below declaration in vue component:

<script lang="ts">
  export default {
    ...
  }
</script>

When click the highlight part, it will show below content:

The full content is as below:

import mod from "-!../../../node_modules/happypack/loader.js?id=happyTs!../../../node_modules/ts-loader/index.js??clonedRuleSet-4.use[1]!../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./ManageApprovalAction.vue?vue&type=script&lang=ts"; export default mod; export * from "-!../../../node_modules/happypack/loader.js?id=happyTs!../../../node_modules/ts-loader/index.js??clonedRuleSet-4.use[1]!../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./ManageApprovalAction.vue?vue&type=script&lang=ts"

Does anybody know why can not show the original source file content in this case ?

How are you?
Plz ensure that your Webpack configuration accurately reflects the loader settings for both JavaScript and TypeScript files.
You may need to configure vue-loader and ts-loader properly to handle .vue files containing TypeScript.
you can ensure that the mappings are correct and that they point back to the correct *.vue files by using the browser’s developer tools to inspect the generated source maps ,
By ensuring that your loaders are configured correctly, simplifying your logic, and possibly using additional source map loaders, you should be able to improve your debugging experience for Vue components, whether they are written in JavaScript or TypeScript. Make sure to test each change to observe how it affects your source maps in practice.
Happy coding!

New contributor

Diego Vieira Dos Santos is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật