jscad / OpenJSCAD.org

JSCAD is an open source set of modular, browser and command line tools for creating parametric 2D and 3D designs with JavaScript code. It provides a quick, precise and reproducible method for generating 3D models, and is especially useful for 3D printing applications.
https://openjscad.xyz/
MIT License
2.58k stars 507 forks source link

V3: does not start the web UI #1217

Open jbroll opened 1 year ago

jbroll commented 1 year ago

Expected Behavior

git clone git@github.com:jbroll/OpenJSCAD.org.git cd OpenJSCAD.org git checkout V3 pnpm install pnpm test cd pacakges/web pnpm run dev ...

## Actual Behavior ParseError: 'import' and 'export' may appear only with 'sourceType: module' ## Steps to Reproduce the Problem above? ## Specifications - Version: V3 - Platform: mac - Environment: local
z3dev commented 1 year ago

@jbroll welcome

yeah. The web Ui is still work in progress, as some of the dependencies cannot be used with standard import/export.

will post back when something is working again

jbroll commented 1 year ago

I made an attempt to make this work by converting the build commands in the remaining packages to rollup, but I could not get the code to be recognized as modules. Ideas about what direction might work for this?

z3dev commented 1 year ago

Thanks for trying. The problem is webworkify. The internals accumulate code into a single JS block, which gets injected into the webworked. (For those weak in health, avoid looking at the code.)

The trick will be creating a webworker which loads the required packages using imports. I think @hrgdavor might have this functionality in the new prototype, which he has been working on for the last year.

hrgdavor commented 1 year ago

@z3dev yes I have a worker that now can work with folder projects and load imports from unpkg/jsdelivr and node workspaces. There are few bits to test and tune, but it works well and I use it frequently to run my jscad scripts. It also handles TypeScript and ESM modules by converting them on the fly to csj/require.

Anyway, I hate those automatic/automagic worker code generators. That is why I am making the worker as standalone package. When creating a page you need to put it proper location and call it.

I finally have different bits ready for people to produce their own websites. Example here a standalone web page that has jscad with worker.

included in that demo is also my camera gizmo https://github.com/hrgdavor/jscadui/tree/main/packages/html-gizmo that I am very proud of.