Egy Ramschie
Egy Ramschie

Reputation: 53

Vue 3- Nuxt 3 Composables does not console log

I am trying to console.log using composables, it used to work fine but now it just doesn't work. This is what i tried to do:

~/composables/test/index.ts

export function useTester() {
  console.log("try head"); // <-- does not console log

  const trychild = () => {
    console.log("child tried"); // <- does not console log
  };

  return {
    trychild,
  };
}

~somepath/index.vue

<template>
    <div>
        <button @click="testComposable()"> test composable </button>
    </div>
</template>

<script lang="ts" setup>
import {useTester} from ~/composables/test/index.ts

const testComposable = () => {
  console.log("initate tests"); // <-- this console logs
  const {trychild} = useTester();
  trychild()
}

</script>

I really don't understand what's going on since i remembered clearly that it used to work in the past. Is this a bug?

Upvotes: 2

Views: 959

Answers (1)

Egy Ramschie
Egy Ramschie

Reputation: 53

Nevermind i made a mistake on nuxt.config.ts, in it I did

  vite: {
    esbuild: {
      drop: ["console"], // <-- this was the problem.
    },
  },

I did not know that vite esbuild treated composables as a built file even if its running on the development environment.

Upvotes: 0

Related Questions