Fork me on GitHub
#shadow-cljs
<
2023-05-19
>
cartesian-theatrics20:05:10

Hello, I'm pretty confused about using JS files in shadow-cljs projects. I have a file like src/js/my_project/model_viewer.js which imports BufferGeometry:

import { BufferGeometry } from 'three/build/three.module';

const buff = new BufferGeometry();
I get an error saying BufferGeometry$$module$node_modules$three$build$three_module doesn't exist. But it does actually exist in the compiled module$node_modules$three$build$three_module.js compiled source it's just not loaded I guess. Is there a way to get this to work?

cartesian-theatrics20:05:38

It does work if I do it this way:

import Three from 'three'; // legacy three module

const buff = new Three.BufferGeometry();
But this is not how almost any existing addon scripts import/use Three.js classes, making it impossible to use them.

thheller20:05:04

the direct import of JS files has always been somewhat unreliable. we are mercy of how the closure compiler rewrites the code, and there are certain things that don't work very reliably unfortunately

thheller20:05:20

you might have more luck with commonjs, so require not import

cartesian-theatrics20:05:00

hm, okay thanks I'll give that a shot. Feels like I'm missing something dumb.

thheller20:05:53

nah its just not a heavily used feature. so there are issues. if you want to make a repro I can take a look. sometimes its an easy fix, sometimes not so much

thheller20:05:51

sometimes a clean compile works fine too but a hot-reload or repl load doesn't

thheller20:05:01

as I said .. there are issues 😛

thheller21:05:03

:js-options {:js-provider :closure} why did you set this?

thheller21:05:18

don't set this. it'll almost certainly break everything 😛

cartesian-theatrics22:05:52

... It works now. I told you it was something dumb!

cartesian-theatrics22:05:45

thanks for the help