netless-io/netless-app

Webpack Compatibility or Load NetlessApp object type

parallelmedical opened this issue · 2 comments

I've built a custom plugin using this framework however avoided using svelte.

trying to workout how to port to webpack 4 or ability pass netlessapp type for src instead of string.

any guidance on how i would go about doing this?

export type AddAppParams = {
kind: string;
// app 地址(本地 app 不需要传)
src?: string;
// 窗口配置
options?: AddAppOptions;
// 初始化 attributes
attributes?: any;
};

crimx commented

We are still in the progress of finalizing the API but here is an example of how it looks like right now:

https://github.com/netless-io/flat/blob/ee33feed9d0f8039f85b2d48b7893eaea0685c36/desktop/renderer-app/src/tasks/init-register-apps.ts#L4-L19

thanks, i actually just got it working

webpack alias

'dicomViewer': path.join(__dirname, 'src/whiteboardApps/dicom/src/index.tsx'),

then when joining whiteboard rom

let src = () => import('dicomViewer');
const wrapped = async () => {
if (typeof src === "function") {
const mod = await src();
return "default" in mod ? mod.default : mod;
} else {
return src;
}
};

  WindowManager.register({kind: "test", src: wrapped})