Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Getting depthkit__WEBPACK_IMPORTED_MODULE_5___default.a is not a constructor on imported npm module instantiation. #11

Open
heaversm opened this issue Jun 23, 2020 · 4 comments

Comments

@heaversm
Copy link

Using:

npm i depthkit
import Depthkit from "depthkit";
const depthkit = new Depthkit(); //error

How do I properly import this as a module?

@wpreble1
Copy link

wpreble1 commented Feb 5, 2021

I had a similar issue with trying to use an ES6/webpack workflow. I was able to solve it by copying the contents of src/depthkit.js into my own repo. Then import directly from that file import DepthKit from './depthkit';. Then, copy lines 61 and 62 from build/depthkit.js, which contain the contents of the shaders, and replace lines 29 and 30 in src/depthkit.js. Then run npm i glslify and uncomment line 15 to make sure Three is referenced in depthkit.js.

@oliverellmers
Copy link

Hello,

I am trying to get the Depthkit.js player to work as a module for me also. I have followed your above instructions, but running into an error with the line const glsl = require('glslify'); - the error being:

Uncaught ReferenceError: require is not defined at depthkit.js:18 (anonymous) @ depthkit.js:18

I was wondering if you have experienced the same problem or have a potential solution?

Thanks

@ROBYER1
Copy link

ROBYER1 commented Dec 2, 2022

Same issue here, why is this a package if it can't be used properly as a module? Any fix?

@ROBYER1
Copy link

ROBYER1 commented Dec 2, 2022

I tried replacing const glsl = require('glslify'); with

import glslify from 'glslify';
// bundling of GLSL code
//const glsl = require('glslify');
const glsl = glslify;

Now I get the error: Error: It appears that you're using glslify in browserify without its transform applied. Make sure that you've set up glslify as a source transform:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants