ammojs-typed icon indicating copy to clipboard operation
ammojs-typed copied to clipboard

loader bug with vite

Open drewp opened this issue 2 years ago • 3 comments
trafficstars

I don't know the actual cause, but I am using vite FWIW.

import Ammo from "ammojs-typed";

loadAmmo = Ammo(Ammo);
ammo.js:978 Uncaught TypeError: Cannot set properties of undefined (setting 'Ammo')
    at ammo.js:978:325

Workaround:

import Ammo from "ammojs-typed";

loadAmmo = Ammo.bind(Ammo)(Ammo);
(success)

Here's my tsconfig:

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "alwaysStrict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "strict": true,
    "strictFunctionTypes": true,
    "strictNullChecks": true,
    "strictPropertyInitialization": true,

    "allowJs": true,
    "declaration": true,
    "downlevelIteration": true,
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "module": "ES6",
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "ES6",
    "traceResolution": true,
    "useDefineForClassFields": false,

    "lib": ["es2022", "dom", "ES2019.Object"],
    "types": []
  },
  "include": ["src/**/*.ts"]
}

and selected dep versions:

    "@types/three": "^0.157.2",
    "ammojs-typed": "^1.0.6",
    "three": "^0.158.0",
    "vite": "^4.5.0"
  },
  "devDependencies": {
    "node-globals": "^0.1.5",
    "tslib": "^2.6.2",
    "typescript": "^5.2.2"

drewp avatar Nov 06 '23 05:11 drewp

The workaround worked great for me. Nothing else was working, but that got the job done. Finally hours of suffering are over. Thank you.

wingsandstache avatar Apr 23 '24 10:04 wingsandstache

I'm getting a similar error to before. Any ideas on how to solve this one? Uncaught TypeError: Cannot read properties of undefined (reading 'emscripten_bind_btTransform_btTransform_0')

wingsandstache avatar Apr 23 '24 22:04 wingsandstache

I'm getting a similar error to before. Any ideas on how to solve this one? Uncaught TypeError: Cannot read properties of undefined (reading 'emscripten_bind_btTransform_btTransform_0')

I also encountered the same problem, have you solved it?

xjown avatar May 01 '24 14:05 xjown