babylon-vrm-loader icon indicating copy to clipboard operation
babylon-vrm-loader copied to clipboard

Error: Self is not defined

Open Benjythebee opened this issue 1 year ago • 2 comments

I'm loading this module just as shown in the example:

import * as BABYLON from "@babylonjs/core";
import 'babylon-vrm-loader'

in NextJS and Typescript.

The app crashes instantly:

Error [ReferenceError]: self is not defined
    at Object.<anonymous> (C:\Users\Benjy\Documents\Github\project\s\node_modules\babylon-vrm-loader\dist\index.module.js:1:4903)

Not sure what's going on but would love a fix...

Benjythebee avatar Jul 10 '23 22:07 Benjythebee

Following up:

I went into /dist/index.js and /dist/index.module.js and manually changed self to this;

Now I have the error:

Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users... \@babylonjs\core\Maths\math.js not supported.

Benjythebee avatar Jul 10 '23 22:07 Benjythebee

Thank you for opening issue.

It may be ES target problem https://github.com/virtual-cast/babylon-vrm-loader/blob/master/tsconfig.json#L6 .

Could you share the minimum code that occurs this error, using CodeSandbox or something?

yamayuski avatar Jul 11 '23 00:07 yamayuski