Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glslify will not import (via "require" or "import") #143

Open
Johnrobmiller opened this issue Feb 6, 2021 · 5 comments
Open

glslify will not import (via "require" or "import") #143

Johnrobmiller opened this issue Feb 6, 2021 · 5 comments

Comments

@Johnrobmiller
Copy link

Johnrobmiller commented Feb 6, 2021

glslify looks great, but I think I might have to go without using glslify until I can solve whatever is going on here.

glslify will not import. Here is what I tried:

  • const glsl = require('glslify')
  • import { glsl } from 'glslify'
  • import glsl from 'glslify'
  • import * as glsl from 'glslify
  • import { createRequire } from 'module'; const require = createRequire(import.meta.url); const glsl = require('glslify')
  • installing the glslify babel-plugin
  • reinstalling commonjs
  • installing glslify with and without using th -g tag

No matter what I do, glslify will not import. I get the same errors every time. It's either:

  • Could not find a declaration file for module 'glslify' (when using import)
  • reference error: require is not defined (when using require)

I don't think my setup is too much different from anybody else's. It's just a snowpack build setup with React and Typescript.

Perhaps there was some update in babel or snowpack that broke glslify. I have no idea. Either way, I'm submitting this issue so that it can be out in the public eye, and if I am lucky someone will be able to help me out and post a solution.

@Johnrobmiller Johnrobmiller changed the title glslify will not import glslify will not import (via "require()" or "import") Feb 6, 2021
@Johnrobmiller Johnrobmiller changed the title glslify will not import (via "require()" or "import") glslify will not import (via "require" or "import") Feb 6, 2021
@homerjam
Copy link

homerjam commented Feb 7, 2021

I'm having similar issues I think - pretty sure it's down to this. Some renaming would at least allow to explicitly require the main module file when required. Right now it's completely impossible.

@Johnrobmiller
Copy link
Author

Thanks homerjam. I'm working on something else all day today, but I'll get this a whirl tomorrow.

@Johnrobmiller
Copy link
Author

Welp, I tried the fix above, but sadly, it looks like I've got bigger problems. I wasn't able to modify glslify's package.json because glslify never actually installed. I checked my node_modules, and it is not there. Still, npm reported to have installed it without error. Very strange.

@jeffpeck10x
Copy link

Is there a fix for this? Or has anyone found a suitable workaround?

@jeffpeck10x
Copy link

Oh, this works: https://github.com/onnovisser/babel-plugin-glsl

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

No branches or pull requests

3 participants