xeokit / xeokit-sdk

Open source JavaScript SDK for viewing high-detail, full-precision 3D BIM and AEC models in the Web browser.
https://xeokit.io
Other
728 stars 288 forks source link

src directory is missing when xeokit-sdk is installed via npm #952

Closed intrida-dev closed 6 months ago

intrida-dev commented 1 year ago

We have recently updated the xeokit-sdk to ^2.3.2 and observed that we are not able to load 3dxml datasets anymore, because, there is not zipjs directory. So we checked in node_modules and found out that src directory missing there, which used to be there earlier this year (Jan was the last time we might have checked it).

I am sending you the screenshot of how what folders are installed in node_modules. image

Please let us know, how can we make this working.

xeolabs commented 1 year ago

Thanks - I don;t think we want src in the npm distribution, so the fix here would be to include zipjs in the built library.

intrida-dev commented 1 year ago

Thanks for reply, Lindsay. Including zipjs in the built library means copying whole src folder from github and place it in node_modules->@xeokit->xeokit-sdk, right?

xeolabs commented 1 year ago

I haven't looked closely yet, but yes it probably requires the zipjs library to be deployed into the dist directory, since that dir does contain a WASM module needed by zipjs, which can't be included in the xeokit JS library itself.

Amoki commented 1 year ago

I think there is a more generic problem to solve: Plugins may have heavy and diverse dependencies (zipjs for 3dxml, loaders.gl for las, web-ifc for ifc, etc). Bundling everything for everyone, even if they don't use these plugins makes the dist very big. Keeping the dependencies away from the dist makes it hard to use.

We have similar problems at BIMData and I can explain how we do if you're interested!

xeolabs commented 1 year ago

Agreed, I will be looking at ways to separate the plugins into their own repositories. Hugo if you could share your explanation, that would be great.

Amoki commented 1 year ago

At BIMData we do something hybrid: Plugins that are almost always used and without significant dependencies are embedded in the main build, while less used or big plugins are in other npm packages.

We have the main package: https://www.npmjs.com/package/@bimdata/viewer and the plugins (eg: https://www.npmjs.com/package/@bimdata/gltf-extractor-viewer-plugin)

For xeokit, it could be:

Plugins can be either :

Imho, easy CI/CD is easier to maintain than less dispatched content. Xeokit has a stable API so I don't think plugin releases must be synced with the SDK. A plugin made with xeokit 2.2 will work with xeokit 2.3. Therefore, I advise 1 git repo for each plugin that is not in the main repo.

We use https://www.npmjs.com/package/semantic-release to manage each plugin. The release and changelogs are automated with the CI and make all our plugins easy to maintain.

The last problem to solve is dependencies on xeokit itself. If plugins are in another code base, we can't do import {Map} from "./../../viewer/scene/utils/Map.js"; I see two solutions: Injecting dependencies in the plugin init:

- import * as xeokitSdk from "@xeokit/xeokit-sdk";
- new xeokitSdk.GLTFLoaderPlugin(viewer, cfg);

+ import * as xeokitSdk from "@xeokit/xeokit-sdk";
+ import GLTFLoaderPlugin from "@xeokit/xeokit-gltf-plugin";
+ new GLTFLoaderPlugin(xeokitSdk, viewer, cfg);

Or flagging in the build xeokit as an external dependency:

- import {Map} from "./../../viewer/scene/utils/Map.js";

+ import {scene} from "@xeokit/xeokit-sdk";
scene.utils.Map
xeolabs commented 1 year ago

Thanks for your input @Amoki

Yip I agree that having each "non-core" plugin in its own repo, with core plugins bundled with the Viewer, is the way to go.

I'm not quite getting that last snippet though - could you expand on how that's working?

Amoki commented 1 year ago

The last snippet doesn't work currently. I checked the code and everything seems to be exported, hopefully without conflict.

So the snipper could just be

- import {Map} from "./../../viewer/scene/utils/Map.js";
+ import {Map} from "@xeokit/xeokit-sdk";
kvandake commented 1 year ago

I use only XKTLoaderPlugin in my react app, but I don`t use other plugins. I looked the repo and I see next steps:

I'm ready to help.

kvandake commented 1 year ago

I use only XKTLoaderPlugin in my react app, but I don`t use other plugins. I looked the repo and I see next steps:

  • separate each plugin on npm package
  • transform to monorepa with lerna
  • transform ci/cd for deploy each plugins

I'm ready to help.

Because some libraries not user friendly for react

kvandake commented 1 year ago

I created a merge request based my fork project. I was able to deploy separate packages as

https://github.com/xeokit/xeokit-sdk/pull/960

Снимок экрана 2022-11-17 в 10 39 15