piqnt / stage.js

2D HTML5 rendering and layout engine for game development
http://piqnt.com/stage.js/
Other
2.43k stars 241 forks source link

Uncaught ReferenceError: DEBUG is not defined | Stage.js 0.9.4 + Vue.js v3.3.4 #63

Open LuckyFox31 opened 1 year ago

LuckyFox31 commented 1 year ago

Stage.js version : 0.9.4 Vue.js version 3.3.4 Development environment : Vite Package manager : PNPM 8.6.9

I created a small project with the Vue.js framework to test the Stage.js library.

When I try to import the library I get an error:

Uncaught ReferenceError: DEBUG is not defined
    at node_modules/.pnpm/stage-js@0.9.4/node_modules/stage-js/lib/core.js (core.js:2:3)
    at __require (chunk-76J2PTFD.js?v=a126181c:3:50)
    at node_modules/.pnpm/stage-js@0.9.4/node_modules/stage-js/lib/index.js (index.js:1:18)
    at __require (chunk-76J2PTFD.js?v=a126181c:3:50)
    at node_modules/.pnpm/stage-js@0.9.4/node_modules/stage-js/platform/web.js (web.js:1:18)
    at __require (chunk-76J2PTFD.js?v=a126181c:3:50)
    at web.js:16:1

This error appears in this import:

import {Stage} from "stage-js/platform/web.js"

I also tried this import:

import {Stage} from "stage-js"

Here is my code :

<script setup>
  // -- Dependencies --
  import {ref, onMounted} from "vue";
  import {Stage} from "stage-js/platform/web.js" // <-- Here

  // -- References --
  const gameContainer = ref(null);

  // -- Variables --
  let stage;

  // -- Life cycles --
  onMounted(() => {
    stage = new Stage(gameContainer.value);
  })
</script>

<template>
  <div ref="gameContainer"></div>
</template>

<style scoped>
  div{
    width: 1000px;
    height: 1000px;
  }
</style>

Has anyone ever encountered this error? How can I solve this problem?

shakiba commented 1 year ago

Hi @LuckyFox31 , please temporary add var DEBUG = false; or true to your code, I'm working on a new major update, but will make an minor update to just a fix this issue today.

shakiba commented 1 year ago

I published 0.9.5, could you please try again?

LuckyFox31 commented 1 year ago

It works, thank you.

But now I have to use this syntax to import the library:

import * as Stage from "stage-js" // Work

import {Stage} from "stage-js/platform/web.js" // Not working
import {Stage} from "stage-js"// Not working

I can't wait to see the new version! ;)

Thanks for the fix!