react-gbajs icon indicating copy to clipboard operation
react-gbajs copied to clipboard

Can't run with Vite & React 17

Open SaadBazaz opened this issue 2 years ago • 6 comments

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"
  }
}

SaadBazaz avatar Jun 14 '23 21:06 SaadBazaz

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 ?

OrlandoNatsu avatar Oct 11 '23 23:10 OrlandoNatsu

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.

SaadBazaz avatar Oct 12 '23 00:10 SaadBazaz

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

macabeus avatar Oct 12 '23 08:10 macabeus

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

  • Loading bin file: assets/bios.bin or injected as bytearray
export default defineConfig({
  assetsInclude: ['**/*.bin'],
})
  • upgrade dependencies (dev, peer), now is React 18+, node 18+

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

TimKieu avatar Apr 12 '24 17:04 TimKieu

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

macabeus avatar Apr 15 '24 09:04 macabeus

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

kaluxxx avatar May 24 '24 17:05 kaluxxx