Conversation
…paste issue fixed bug in packages/web/postInstall.js that prevented installing @jscad/web, when the examples were not loaded. Adds a umd build target based on opt.js. umd.js and processor-bare.js are usable by different bundlers like webpack. Added eslint and prettier config files to prevent vscode from automatically formatting exsiting OpenJsCad files.
|
Thanks for the huge PR @johnwebbcole ! Standalone UMD Build
umd.js and processor-bare.js
eslint and prettier files
postInstall.js
jscad-viewer-lightgl.js
Why modify the 1.x version?
General
|
|
@kaosat-dev hey, thanks for all your hard work too... as I mentioned, a clean UMD module wasn't really possible earlier. VuePress is indeed a lot like Gatsby but not quite as extensive. The vue component package will be a lot like the open-jscad.vue component in the <open-jscad design="vesa-shelf.jscad" :panel="{size:223}" :camera="{position: {x: 0, y: 0, z: 223},clip: {min: 1, max: 1000}}"></open-jscad>And handles resizing and update isolation (so Vue won't re-render a section, React has the same guards). I think a React component package should be just as easy. I'm not a React expert, so I'll leave that one up to you :-) I would appreciate some help getting the test working, I'm not sure what was wrong there. The master branch has the same error. I've pulled the eslint and prettier config files. Though it may be a good idea to add them in the future, even if they are telling it NOT to run on files. :-) I had them in so VSCode wouldn't reformat everything. If you see any changes that can be made to make V2 issues easier, let me know. |
|
@johnwebbcole ah ok, I see nice and clean vue component you got there ! I usually prefer more 'vanilla' js functions instead of components/custom elements, but the one you have is really nice !
not quite sure : we could make some changes to make it closer to V2 , then again, that might be premature, and since V2 is a breaking version, perhaps just not worth the hassle |
|
@johnwebbcole could you please bump the dependencies on the translator module to 0.0.11 ? |
| "license": "MIT", | ||
| "main": "dist/openjsad.umd.js", | ||
| "main": "dist/openjscad.umd.js", | ||
| "module": "dist/openjscad.umd.js", |
There was a problem hiding this comment.
what is the status for the support of the 'module' field ? I used to use it a few years back, then it seemed to go out of fashion and now is back again (saw some es module listings using it to get all npm modules with direct import support)
There was a problem hiding this comment.
Rollup, Webpack and Browserify to an extent use this during bundling. The "browser" field is the standard one, but will fall back to "main" if it doesn't exist. "module" tells the major bundlers to use that file instead of attempting to use the src files (which aren't set).
The upshot is that you can use an import like:
const openjscad = require('@jscad/web')instead of
const openjscad = require('@jscad/web/dist/openjscad.umd.js')And if we decide to change the default exported file, we can control that without everyone
chaging their import/requires.
"module" will get skipped by node, and the browsers.
|
yay, thanks for updating ! tests are now passing, will try to merge either tonight or tomorrow at the latests. |
kaosat-dev
left a comment
There was a problem hiding this comment.
@johnwebbcole I wanted to merge this morning, but took a closer look at everything : would you mind discussing the points I mentioned before we can merge ? Thanks !
And sorry, not wanting to nitpick, but I think they are point worth digging a bit more into.
|
As someone following along from the sidelines thank you for an excellent pull request and an excellent review process. These changes help me a lot, and I am impressed with the way this project is being run. |
#402, #344, #343, #300 and possibly others.
Standalone UMD Build
This adds two files for a new build target with the
--standaloneswitch. It creates a UMD version of OpenJSCAD that can be loaded with other bundlers or embedded in another web application with a script tag.These changes were not possible a few months ago, but the fantastic work being done to provide a common core based on the @jscad libraries has really paid off. This MR does not replace or impact the #382 overhaul, it is intended to leverage exiting changes to give a web installable version. It's my hope that #382 will include a UMD build as well when it is complete.
Here is an example site using the UMD build: https://johnwebbcole.gitlab.io/vesa-shelf/
umd.js and processor-bare.js
The two new files build on
opt.jsandprocessor.jsto provide a minimal export function that allowsan application to create a jscad viewer. I have been able to create a vue component that allows you to include a
.jscadfile in a vuepress static site. The vesa-shelf project inclues a gitlab cicd file that creates a gitlab pages (similar to github pages) site using vuepress. https://johnwebbcole.gitlab.io/vesa-shelf/ uses the umd build (I published a version under my scope,@jwc/jscad-webto try it out) which gives me a way to publish live versions of a project, without relying on the public https://openjscad.org/ site.I plan on publishing a vue-openjscad package, based on the code in
vesa-shelfusing a UMD build soon.I'll also update the yeoman generator-jscad with an option to generate the vuepress site using the
vue-openjscadpackage.eslint and prettier files
These were added to prevent vscode from auto formatting the base @jscad files. I'll happily remove these if desired.
postInstall.js
When loading the
@jscad/webpackage, the postInstall step throws an error because the examples aren't loaded. Added a check for the examples directory to get around this issue.jscad-viewer-lightgl.js
Fixed a cut and paste issue, it was generating weird html in the
viewerdivelement.Why modify the 1.x version?
So why allow a change in 1.x? Here are a few reasons I hope will persuade everyone.
The web overhaul for the 2.x version is looking great. I'm looking forward to it, but it's not ready yet, and there is no need to rush anything.
Having an embeddable version of the 1.x branch provides a lot of insulation for the new 2.x site. If a project encounters issues with the new 2.x website, you can create an embedded version of the 1.x site.
In my opinion, the lack of an embeddable version is a primary reason against adoption of OpenJSCAD. The main libraries are starting to see adoption because they are reusable. I think the same will happen with a reusable viewer also.
And finally, these are minor changes, reusing existing code and almost no changes to existing files (except for the bug fixes). I think making a 1.10.0 version adding this feature will not impact on the existing code base, nor complicating the 2.x efforts.
Changes
fixed bug in packages/web/postInstall.js that prevented installing @jscad/web,
when the examples were not loaded.
Adds a umd build target based on opt.js. umd.js and processor-bare.js
are usable by different bundlers like webpack.
Added eslint and prettier config files to prevent vscode from automatically formatting
exsiting OpenJsCad files.
All Submissions:
Thank you for your help in advance, much appreciated !