Fork me on GitHub
#portal
<
2023-06-09
>
Sam Ritchie04:06:09

Next challenge… https://github.com/djblue/portal/blob/master/src/portal/ui/load.cljs#L44 seems to be having trouble with a dependency where I’ve explicitly specified the ES6 module version of a file: https://github.com/mentat-collective/MathBox.cljs/blob/main/src/mathbox/core.cljs#L5

Sam Ritchie04:06:12

@djblue I was also seeing a failure requiring "threestrap", even if I specified "type": "module" in package.json: https://github.com/unconed/threestrap/blob/master/package.json#L9 because "main" was pointing to a module, not to a built bundle

Sam Ritchie04:06:10

I fixed that error by manually (in node_modules, for testing) modifying the package.json of https://github.com/unconed/threestrap, https://github.com/unconed/shadergraph and https://github.com/unconed/mathbox to point to built bundles, but three.js is explicitly deprecating the non-module versions of all of their stuff soon

Sam Ritchie04:06:22

any thoughts on how to handle this case?

Sam Ritchie04:06:27

looks like it might be possible to transpile it at runtime

Sam Ritchie04:06:52

or server-side via load I guess

djblue04:06:45

is there a commonjs version of the module or is it only es module?

djblue04:06:42

Looks like 'threestrap/build/threestrap.js' is require-able

djblue04:06:57

Ohh, I see now that you already mentioned doing that above 😆

Sam Ritchie04:06:20

The killer is the first link, where I import in mathbox.cljs the module version of OrbitControls.js (since that’s what three.js wants, I don’t know if they still publish a non-module version?)

Sam Ritchie04:06:39

And they will stop in a few versions for the main “three” dependency

djblue04:06:41

I didn't think the npm support would run into this issue so quickly, why does js have to be this way lol

djblue04:06:37

For shadow, does the code get parsed / analyzed to determine commonjs vs es6?

Sam Ritchie04:06:12

I am not sure, I am similarly flummoxed by the JS world here

djblue04:06:36

I think the worst part about this is that esmodules have such varied / complex syntax 😭

djblue04:06:19

I wish they had just used the exist language syntax of function calls, then mocking an implementation would be trivial

💯 2
Sam Ritchie13:06:01

JSXGraph.cljs works now, just needs styling… @djblue mathbox is the only one left to fall 🙂

metal 8
👏 5
🤯 4
🎉 5
djblue16:06:41

Is es module support a hard requirement for getting mathbox working?

Sam Ritchie17:06:45

@djblue ugh, unfortunately it is because threejs removed all of the non-module controls instances. https://github.com/mrdoob/three.js/blob/dev/examples/jsm/controls/OrbitControls.js

Sam Ritchie17:06:56

so I COULD transpile this one file and then we’d be okay, if it’s going to be a nightmare

Sam Ritchie17:06:01

but that is the only blocker so it’s not crazy

Sam Ritchie17:06:34

@djblue and then leva is working great… at some point I’ll need to bump portal to catch that npm fix you applied

Sam Ritchie18:06:02

Every other library in this series works now @djblue !

djblue18:06:51

What if... we just ship babel as part of the ui code 😆

djblue19:06:52

Bundle goes from 4.1 to 5.1 mb 😂

Sam Ritchie19:06:57

geometry theorems via portal

🎉 3
JAtkins07:09:59

a little late but, is it possible to do this for d3-force? I'd like to require that but it's an es module as well and seems to not be on the commonjs path

djblue19:09:40

I tested d3-force with the Babel branch and it does load, but I'm still not sure about the cost benefit here :thinking_face:

djblue19:09:47

The alternative would be to get the browser to load the esm module, which should be natively supported for the most part. I haven't played around with that yet.

JAtkins20:09:03

is there any reason that the intellij plugin would behave differently? I assume it's not built on electron but I haven't checked so it may be the same

djblue21:09:34

Sorry, the Babel branch hasn't been released yet if you are using a released version of portal.

JAtkins21:09:57

right, just asking generally

djblue21:09:43

For the most part, the intellij plugin should be acting as a browser window for the portal app that's being hosted by the REPL process. I think people have experienced some issues around some of the native inputs acting a little weird, but the client code is identical to running it in any other browser client.

👍 1
JAtkins21:09:17

I just built the jar and gave the ESM version a spin - works great! I honestly am not familiar enough with the JS landscape to know if there is another better solution than this, but I can confirm that the PR branch is very useful 🙂

djblue00:09:46

@U5P29DSUS actually, it looks like d3-force exports a umd module which is consumable without esm support. Should "just work" after https://github.com/djblue/portal/commit/86b2b61e9edc7c599726701f1ee75a8601c4373e is released.