Skip to content

[FIX]: ESM Cannot set properties of undefined (setting 'adapter') #2396

@Dean-Overton

Description

@Dean-Overton

Firstly, thanks for your work on this project!

Today I used patch-package to patch @luma.gl/[email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/@luma.gl/webgl/dist/adapter/webgl-adapter.js b/node_modules/@luma.gl/webgl/dist/adapter/webgl-adapter.js
index 51edaee..023ee3f 100644
--- a/node_modules/@luma.gl/webgl/dist/adapter/webgl-adapter.js
+++ b/node_modules/@luma.gl/webgl/dist/adapter/webgl-adapter.js
@@ -14,8 +14,11 @@ export class WebGLAdapter extends Adapter {
         super();
         // Add spector default props to device default props, so that runtime settings are observed
         Device.defaultProps = { ...Device.defaultProps, ...DEFAULT_SPECTOR_PROPS };
-        // @ts-ignore DEPRECATED For backwards compatibility luma.registerDevices
-        WebGLDevice.adapter = this;
+        if (typeof WebGLDevice !== 'undefined') {
+            // @ts-ignore DEPRECATED For backwards compatibility luma.registerDevices
+            WebGLDevice.adapter = this;
+            console.log('[PATCH] WebGLDevice.adapter set safely');
+        }
     }
     /** Check if WebGL 2 is available */
     isSupported() {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions