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
@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
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
any thoughts on how to handle this case?
looks like it might be possible to transpile it at runtime
or server-side via load I guess
is there a commonjs version of the module or is it only es module?
Looks like 'threestrap/build/threestrap.js' is require-able
Ohh, I see now that you already mentioned doing that above 😆
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?)
And they will stop in a few versions for the main “three” dependency
I didn't think the npm support would run into this issue so quickly, why does js have to be this way lol
For shadow, does the code get parsed / analyzed to determine commonjs vs es6?
I am not sure, I am similarly flummoxed by the JS world here
I think the worst part about this is that esmodules have such varied / complex syntax 😭
I wish they had just used the exist language syntax of function calls, then mocking an implementation would be trivial
I think https://stackoverflow.com/questions/57121467/import-a-module-from-string-variable might be part of a solution
JSXGraph.cljs works now, just needs styling… @djblue mathbox is the only one left to fall 🙂
Is es module support a hard requirement for getting mathbox working?
@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
so I COULD transpile this one file and then we’d be okay, if it’s going to be a nightmare
but that is the only blocker so it’s not crazy
@djblue and then leva is working great… at some point I’ll need to bump portal to catch that npm fix you applied
Every other library in this series works now @djblue !
What if... we just ship babel as part of the ui code 😆
amazing!
Bundle goes from 4.1 to 5.1 mb 😂
geometry theorems via portal
cc @zane
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
not sure!
I tested d3-force with the Babel branch and it does load, but I'm still not sure about the cost benefit here 🤔
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.
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
Sorry, the Babel branch hasn't been released yet if you are using a released version of portal.
right, just asking generally
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.
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 🙂
@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.
👀 Nice
Ok, should be available with the https://github.com/djblue/portal/releases/tag/0.48.0 release.