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

indexedDB is not defined #63

Open
alvintheodora opened this issue Nov 21, 2023 · 9 comments
Open

indexedDB is not defined #63

alvintheodora opened this issue Nov 21, 2023 · 9 comments

Comments

@alvintheodora
Copy link

Environment:
vue3-emoji-picker: 1.1.8,
Framework: Vue 3
OS: macOS 13.3
Browser : [Chrome Version 116.0.5845.179 (Official Build) (arm64)]

Description:
ReferenceError: indexedDB is not defined error message appear when I run unit testing with vitest.

Expected Behavior:
There should be an option to not use the indexedDB so it will not reproduce the error

Additional Context:
Do we have option to disable the usage of indexedDB?

Thank you in advance for your assistance!

@Drillan767
Copy link

This issue is blocking my deployments 😞

@plfort
Copy link

plfort commented Nov 29, 2023

You can install fake-indexeddb as a dev dependency and load it in vite.config.js:

export default defineConfig({
        test: {
            setupFiles: [
                 //...
                "fake-indexeddb/auto" // required for EmojiPicker
            ],
//...

@alvintheodora
Copy link
Author

My workaround in my nuxt 3 app is to load the component with defineAsyncComponent, like:

import "vue3-emoji-picker/css";
...
const EmojiPicker = defineAsyncComponent(() =>
  import("vue3-emoji-picker").then((EmojiPicker) => EmojiPicker)
);

@andre-w2
Copy link

It works for me, I did it this way.
I added the following line to the nuxt.config.js file:
build: { transpile: [ 'vue3-emoji-picker' ] },

and so created a folder and a file modules/register-component.ts
register-component.ts:

import { addComponent, defineNuxtModule } from '@nuxt/kit'

export default defineNuxtModule({
  setup() {
    addComponent({
      name: 'EmojiPicker',
      filePath: 'vue3-emoji-picker',
      mode: "client"
    })
  },
})

@ghost
Copy link

ghost commented Apr 30, 2024

I have also encountered this issue and hope the developers can solve it as soon as possible. Thank you. The above measures are not effective. I am using nuxt3

@AndreasFaust
Copy link

AndreasFaust commented Aug 8, 2024

The problem is Nuxt’s Server-Rendering: IndexedDB exists only in the browser and not on the server.
Wrap the emoji-picker in Nuxt’s ClientOnly-Component and it works.

https://nuxt.com/docs/api/components/client-only

@genu
Copy link

genu commented Aug 8, 2024

Its an unfortunate workaround. Something like this shouldn't be so tightly coupled with IndexedDB

@AndreasFaust
Copy link

Of course it’s not an ideal solution. It’s just a pragmatic way to make this otherwise great library work in Nuxt.

@hoiles
Copy link

hoiles commented Aug 29, 2024

I had the same issue and I fix it with:

Adding the ''vue3-emoji-picker'' to the nuxt.config file

build: { transpile: ['vue3-emoji-picker'], }, runtimeConfig: {

Create a plugin ' vue-emoji-picker.client.ts'

`import EmojiPicker from 'vue3-emoji-picker'
import 'vue3-emoji-picker/css'

export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.component('EmojiPicker', EmojiPicker)
})
`
Add your picker:

<emoji-picker v-if="showEmojiPicker" :native="true" @select="onSelectEmoji" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants