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
import() fails when you have a variable string importing a Vue component #813
Comments
@antfu is this released? Still having the issue on |
It failes because they are not equal objects. That is another issue. Importing works fine |
🤦 Sorry, still having the issue on my project, will need to investigate further, apologies for this |
@sheremet-va Dig a bit further and I can confirm the error is still there, should I create another issue or we can reuse this one? https://stackblitz.com/edit/vitest-dev-vitest-pnp26x?file=src%2Fcomponents%2FHelloWorld.vue <script>
import { ref, defineComponent, watch } from 'vue';
export default {
props: {
type: String,
},
setup(props) {
console.log('some', ref);
const Comp = ref('div');
watch(
() => props.type,
async (type) => {
import('./editors/Text.vue')
.then((e) => {
console.log('[String] resolved as expected');
return e;
})
.catch((e) => {
console.error('[String] Failed', e);
});
import(`./editors/Text.vue`)
.then((e) => {
console.log('[String-2] resolved as expected');
return e;
})
.catch((e) => {
console.error('[String-2] Failed', e);
});
Comp.value = await import(`./editors/${type}.vue`)
.then((e) => {
console.log('[Dynamic] resolved');
return e;
})
.catch((e) => {
console.error('[Dynamic] Failed', e);
});
},
{
immediate: true,
}
);
return {
Comp,
};
},
};
</script>
<template>
<div>
<!-- <span>Hello There</span> -->
<component :is="Comp" />
</div>
</template>
Expected output
Hopefully I'm not making a silly mistake :D I had a couple coffee today, but you never know :D |
Describe the bug
When you use
import()
if the string is a variable it doesn't work, if is a variable it must have an absolute path.From my findings the request fails here directRequest, the
id
seems to still be the string provided on the import, when you pass a static string it will convert the relative path into the absolute.Reproduction
StackBlitz
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: