HamadaFMahdi / vue-rewards

Vue-rewards lets you add micro-interactions to your app, and rewards users with the rain of confetti, emoji or balloons in seconds.
https://vuerewards.netlify.app
MIT License
104 stars 6 forks source link

The requested module does not provide an export named #2

Open JohnyDyxt opened 8 months ago

JohnyDyxt commented 8 months ago

Hi,

I got :

The requested module '/node_modules/vue-rewards/dist/vue-rewards.umd.cjs?import' does not provide an export named 'useReward'

Here's my code :

CONFIG :

@quasar/app-vite@1.7.3 vue@3.3.13

Thank for helping

HamadaFMahdi commented 8 months ago

Hi!

I just tried it with a fresh vue3 + vite project and it works fine.

Here's the one I made: https://codesandbox.io/p/devbox/vue-rewards-test-73q2ct

JohnyDyxt commented 8 months ago

Hello and thank you for your response.

Unfortunately, it's impossible to get it to work at my place. Perhaps it's because I'm using the Quasar framework and their Vite plugin?

cpilson commented 5 months ago

This feels like a Quasar issue.

Specifically, it would be unsurprising if this page were the ultimate resolution; I'm new to Quasar and new to Vue so this is all fairly puzzling.

https://quasar.dev/app-extensions/tips-and-tricks/provide-a-ui-component/

@JohnyDyxt are you still struggling with this? There's at least TWO of us if so! (Update: I'm now using canvas-confetti, e-z.)

I took a swipe at it, no luck:

app/src/boot/vue-rewards.js:

import { boot } from 'quasar/wrappers';
import VueRewards, { useReward } from 'vue-rewards';

export default boot(({ app }) => {
  app.config.globalProperties.$VueRewards = VueRewards;
  app.config.globalProperties.$useReward = useReward;
});
export { useReward };

app/quasar.config.js:

// app boot file (/src/boot)
  // --> boot files are part of "main.js"
  // https://v2.quasar.dev/quasar-cli-vite/boot-files
  boot: [
    ...
    'vue-rewards',
  ],
  ...

Vue component where it's used:

<script setup lang="ts">
...
import { useReward } from 'src/boot/vue-rewards';
const { reward: fullPageReward } = useReward('full-page', 'confetti', { startVelocity: 10, spread: 180, elementCount: 100 });
...
        $q.notify({
          color: 'green-4',
          textColor: 'white',
          icon: 'cloud_done',
          message: 'Submitted',
          onDismiss: () => {
            fullPageReward();
            ctaDialog.value = false;
          }
        });