FranckFreiburger / vue3-sfc-loader

Single File Component loader for Vue2 and Vue3. Load .vue files directly from your HTML. No node.js environment, no build step.
MIT License
1.19k stars 127 forks source link

Include SourceMaps #198

Open tucker87 opened 3 months ago

tucker87 commented 3 months ago

Hey all, I've spent some free time the last couple weeks digging into this project. And I have a loose grasp on it now.

I really want to use this but I find debugging errors to be quite challenging so I set out to see if I could get sourceMaps to show up.

I see some notes in the code about removing sourceMaps so maybe I'm missing some other feature that helps with this issue?

I've push my work so far here. (The changes are a mess, and many are just trial/error) https://github.com/tucker87/vue3-sfc-loader

image image

I've gotten the source maps to show up and the error message does have a link to the error. But the line seems to be wrong, it's one line lower than it should be. This may be due to the code being wrapped in an anonymous function just before it is read?

Note: The .mjs.v file comes from the intermediary code. It was being called "unknown" and I just gave it a name to help me debug.

Is this a feature I should continue to work on?

tucker87 commented 3 months ago

In case you want to replicate my test.

mycomponent.vue

<template>
    Hi {{ a }} {{ b }}
</template>

<script setup>
import {ref} from 'vue'
import b from './index.mjs'

const a = ref(null)
a.value = 1

console.log(a)

//console.log(b)

</script>

index.mjs

console.log('index.mjs running')
a = 2;
let a = 1;

console.log(a)

export default a