Open kleinpetr opened 2 years ago
The suggestion from the console does work
import pkg from 'vue-toastification';
const { POSITION, TYPE, useToast } = pkg;
This I believe happens when the esm files get transpiled and the transpilation would be
const pkg = require("vue-toastification");
not const POSITION = require("vue-toastification").POSITION
for every different exported member
The suggested notation doesn't work for me. I had a similar problem and solved it this way:
import * as pkg from "vue-toastification"
const { useToast } = pkg
We need to import all the exported contents of the javascript file.
@barszczuPro answer worked for me instead of the suggested notation.
I am using Laravel and Inertia-ssr with Vue. I am facing this issue Named export 'useToast' not found.. I've tried all above solutions but it didn't work. Any other update on this issue?
@barszczuPro solution didn't work for me
but I solved with this:
import * as Toast from "vue-toastification/dist/index.mjs"
import SimpleToast from '@/components/SimpleToast/SimpleToast.vue'
const { useToast } = Toast
export function useNotification() {
const toast = useToast()
const success = (message: string) => {
toast({ component: SimpleToast, props: { type: 'Success', message } })
}
const error = (message: string) => {
toast({ component: SimpleToast, props: { type: 'Error', message } })
}
return { success, error }
}
now vite found esm
The suggested notation doesn't work for me. I had a similar problem and solved it this way:
import * as pkg from "vue-toastification" const { useToast } = pkg
We need to import all the exported contents of the javascript file.
this is working
Versions
Describe the bug
When I try build with vite-ssg I've got these error, but locally works well
Steps to reproduce
Your Environment
Additional context
App is based on Vitesse template where are UserModules which I am using to register toastification, here is my example