Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite + Vue3 uses An error is reported in the production environment after the build #197

Open
coffin03 opened this issue Jul 17, 2024 · 0 comments
Labels
bug Something isn't working unconfirmed Unconfirmed issue

Comments

@coffin03
Copy link

coffin03 commented Jul 17, 2024

Vite + Vue3

An error is reported in the production environment after the build

It is used normally in the development environment

Can it be used after packaging?

TypeError: unknown file: Cannot destructure property 'parentPath' of 's' as it is undefined.

image

<template>
    <div>
        <component :is="remote" v-if="remote" :="props.propsData" />
    </div>
</template>

<script setup lang="ts">
import { loadModule } from "vue3-sfc-loader"
import * as Vue from 'vue'
import { onMounted, defineAsyncComponent, ref, watchEffect } from "vue"


let remote = ref()

const props = defineProps({
    propsData: {
        type: Object,
        required: false
    },
    code: {
        type: String,
        required: true
    },
    fileName: {
        type: String,
        required: true
    }
})


onMounted(() => {
    load()
})

const load = async (code?: string) => {
    console.log(props, 'props--load')
    let res = props.code

    console.log(res, 'res---load')

    const options = {
        moduleCache: {
            vue: Vue
        },
        async getFile() {
            return res
        },
        addStyle(textContent) {
            const style = Object.assign(document.createElement('style'), { textContent })
            const ref = document.head.getElementsByTagName('style')[0] || null
            document.head.insertBefore(style, ref)
        },
        log(type: string, data: any[]) {
            console.log(type, data, 'log')
        }
    };

    remote.value = defineAsyncComponent(() => loadModule(props.fileName || "loader.vue", options))
}
</script>
@coffin03 coffin03 added bug Something isn't working unconfirmed Unconfirmed issue labels Jul 17, 2024
Repository owner deleted a comment from coffin03 Oct 12, 2024
Repository owner deleted a comment from 1103442828 Oct 12, 2024
Repository owner deleted a comment from 1103442828 Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unconfirmed Unconfirmed issue
Projects
None yet
Development

No branches or pull requests

1 participant