macabeus / react-gbajs

🕹 GBA emulator on your React project - easy and powerful to use!
https://www.npmjs.com/package/react-gbajs
BSD 2-Clause "Simplified" License
71 stars 14 forks source link

Can't run with Vite & React 17 #21

Open SaadBazaz opened 1 year ago

SaadBazaz commented 1 year ago

Hey, I'm getting the following error:

arm.js:1 Uncaught ReferenceError: ARMCoreArm is not defined
    at Object.<anonymous> (arm.js:1:1)
    at i2 (bootstrap:19:22)
    at Module.<anonymous> (util.js:245:20)
    at i2 (bootstrap:19:22)
    at bootstrap:83:10
    at node_modules/react-gbajs/dist/react-gbajs.js (bootstrap:83:54)
    at __require (chunk-NCIHTZFX.js?v=f314ad2b:3:50)
    at index.ts:6:16

My project:

{
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "lint": "eslint src --ext js,jsx --report-unused-disable-directives --max-warnings 0",
    "preview": "vite preview"
  },
  "dependencies": {
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-gbajs": "^1.0.3"
  },
  "devDependencies": {
    "@types/react": "^17.0.9",
    "@types/react-dom": "^17.0.9",
    "@vitejs/plugin-react": "^4.0.0",
    "eslint": "^8.38.0",
    "eslint-plugin-react": "^7.32.2",
    "eslint-plugin-react-hooks": "^4.6.0",
    "eslint-plugin-react-refresh": "^0.3.4",
    "vite": "^4.3.9"
  }
}
OrlandoNatsu commented 12 months ago

Hey, I'm getting the following error:

arm.js:1 Uncaught ReferenceError: ARMCoreArm is not defined
    at Object.<anonymous> (arm.js:1:1)
    at i2 (bootstrap:19:22)
    at Module.<anonymous> (util.js:245:20)
    at i2 (bootstrap:19:22)
    at bootstrap:83:10
    at node_modules/react-gbajs/dist/react-gbajs.js (bootstrap:83:54)
    at __require (chunk-NCIHTZFX.js?v=f314ad2b:3:50)
    at index.ts:6:16

My project:

{
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "lint": "eslint src --ext js,jsx --report-unused-disable-directives --max-warnings 0",
    "preview": "vite preview"
  },
  "dependencies": {
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-gbajs": "^1.0.3"
  },
  "devDependencies": {
    "@types/react": "^17.0.9",
    "@types/react-dom": "^17.0.9",
    "@vitejs/plugin-react": "^4.0.0",
    "eslint": "^8.38.0",
    "eslint-plugin-react": "^7.32.2",
    "eslint-plugin-react-hooks": "^4.6.0",
    "eslint-plugin-react-refresh": "^0.3.4",
    "vite": "^4.3.9"
  }
}

could you solve ?

SaadBazaz commented 12 months ago

Hey, I'm getting the following error:

arm.js:1 Uncaught ReferenceError: ARMCoreArm is not defined
    at Object.<anonymous> (arm.js:1:1)
    at i2 (bootstrap:19:22)
    at Module.<anonymous> (util.js:245:20)
    at i2 (bootstrap:19:22)
    at bootstrap:83:10
    at node_modules/react-gbajs/dist/react-gbajs.js (bootstrap:83:54)
    at __require (chunk-NCIHTZFX.js?v=f314ad2b:3:50)
    at index.ts:6:16

My project:

{
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "lint": "eslint src --ext js,jsx --report-unused-disable-directives --max-warnings 0",
    "preview": "vite preview"
  },
  "dependencies": {
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-gbajs": "^1.0.3"
  },
  "devDependencies": {
    "@types/react": "^17.0.9",
    "@types/react-dom": "^17.0.9",
    "@vitejs/plugin-react": "^4.0.0",
    "eslint": "^8.38.0",
    "eslint-plugin-react": "^7.32.2",
    "eslint-plugin-react-hooks": "^4.6.0",
    "eslint-plugin-react-refresh": "^0.3.4",
    "vite": "^4.3.9"
  }
}

could you solve ?

Nope.

macabeus commented 12 months ago

It's probably possible to solve it by replacing ARMCoreArm with window.ARMCoreArm here: https://github.com/macabeus/react-gbajs/blob/7efd0e03c1d36eb0f1bf50c53d97d2215f5d6236/src/emulator/arm.js#L1C1-L1C11

I'm busy with other things, and I might not try it on the following days. If someone is available to test it and open a PR fixing the build when using vite, feel free

TimKieu commented 5 months ago

Yes, @macabeus @SaadBazaz and for Vite React, we should do fix more at:

I am still testing to play the Kage (Shadow Ninja) ^^

macabeus commented 5 months ago

@TimKieu can you open a PR with the fixes, please?

kaluxxx commented 4 months ago

Hello, I have the same problem, I tried to replace ARMCoreArm by window.ARMCoreArm however that does not correct the problem on my side.