portal

Sam Ritchie 2023-06-09T04:09:09.208369Z

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 Ritchie 2023-06-09T04:10:12.868239Z

@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 Ritchie 2023-06-09T04:11:10.341849Z

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 Ritchie 2023-06-09T04:11:22.113109Z

any thoughts on how to handle this case?

Sam Ritchie 2023-06-09T04:12:20.234669Z

https://stackoverflow.com/a/48862511

Sam Ritchie 2023-06-09T04:12:27.734389Z

looks like it might be possible to transpile it at runtime

Sam Ritchie 2023-06-09T04:12:52.212009Z

or server-side via load I guess

djblue 2023-06-09T04:13:45.234969Z

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

djblue 2023-06-09T04:17:42.478439Z

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

djblue 2023-06-09T04:19:57.912929Z

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

Sam Ritchie 2023-06-09T04:21:20.933399Z

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 Ritchie 2023-06-09T04:21:39.377249Z

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

djblue 2023-06-09T04:23:41.989399Z

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

djblue 2023-06-09T04:24:37.267719Z

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

Sam Ritchie 2023-06-09T04:25:12.128689Z

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

djblue 2023-06-09T04:32:36.764619Z

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

djblue 2023-06-09T04:34:19.684029Z

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

💯 1
djblue 2023-06-09T04:47:12.217129Z

I think https://stackoverflow.com/questions/57121467/import-a-module-from-string-variable might be part of a solution

Sam Ritchie 2023-06-09T13:42:01.959619Z

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

👏 3
🤯 2
4
🎉 3
djblue 2023-06-09T16:39:41.753549Z

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

Sam Ritchie 2023-06-09T17:09:45.653719Z

@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 Ritchie 2023-06-09T17:09:56.239339Z

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

Sam Ritchie 2023-06-09T17:10:01.155289Z

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

Sam Ritchie 2023-06-09T17:10:34.879999Z

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

Sam Ritchie 2023-06-09T18:17:02.843199Z

Every other library in this series works now @djblue !

djblue 2023-06-09T18:34:51.340759Z

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

djblue 2023-06-09T18:36:38.796989Z

https://github.com/djblue/portal/pull/182

Sam Ritchie 2023-06-09T18:44:46.815259Z

amazing!

djblue 2023-06-09T19:08:52.474969Z

Bundle goes from 4.1 to 5.1 mb 😂

Sam Ritchie 2023-06-09T19:12:55.266459Z

2
Sam Ritchie 2023-06-09T19:12:57.902209Z

geometry theorems via portal

🎉 2
Sam Ritchie 2023-06-09T19:13:15.063259Z

cc @zane

JAtkins 2023-09-18T07:47:59.728289Z

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

Sam Ritchie 2023-09-18T19:17:04.412919Z

not sure!

djblue 2023-09-18T19:46:40.108139Z

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

djblue 2023-09-18T19:48:47.767179Z

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.

JAtkins 2023-09-18T20:55:03.873119Z

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

djblue 2023-09-18T21:07:34.747879Z

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

JAtkins 2023-09-18T21:07:57.155329Z

right, just asking generally

djblue 2023-09-18T21:10:43.616609Z

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
JAtkins 2023-09-18T21:59:17.650559Z

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 🙂

djblue 2023-09-19T00:25:46.288959Z

@jatkin 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.

JAtkins 2023-09-19T00:26:15.111669Z

👀 Nice

djblue 2023-09-19T03:56:57.383789Z

Ok, should be available with the https://github.com/djblue/portal/releases/tag/0.48.0 release.