From 058271bba9ccf09ff6665e5fabb87b28a1e3c0a9 Mon Sep 17 00:00:00 2001 From: dilesoft Date: Mon, 16 Dec 2024 12:32:43 +0300 Subject: [PATCH] module federation --- .../RulesEditor/components/ContextWrapper/index.tsx | 9 ++++----- src-editor/vite.config.ts | 5 ++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src-editor/src/Components/RulesEditor/components/ContextWrapper/index.tsx b/src-editor/src/Components/RulesEditor/components/ContextWrapper/index.tsx index e780278e..473c52b2 100644 --- a/src-editor/src/Components/RulesEditor/components/ContextWrapper/index.tsx +++ b/src-editor/src/Components/RulesEditor/components/ContextWrapper/index.tsx @@ -2,7 +2,7 @@ import React, { createContext, useEffect, useState } from 'react'; import { type AdminConnection, I18n } from '@iobroker/adapter-react-v5'; -import {init, loadRemote} from '@module-federation/runtime'; +import {registerRemotes, loadRemote} from '@module-federation/runtime'; import ActionSayText from '../Blocks/ActionSayText'; import ActionSendEmail from '../Blocks/ActionSendEmail'; @@ -211,9 +211,8 @@ export const ContextWrapper = ({ children, socket }: { socket: AdminConnection; } try { - init({ - name: obj.common.javascriptRules!.name, - remotes: [ + registerRemotes( + [ { name: obj.common.javascriptRules!.name, entry: url, @@ -221,7 +220,7 @@ export const ContextWrapper = ({ children, socket }: { socket: AdminConnection; } ], // force: true // may be needed to sideload remotes after the fact. - }) + ) const Component = ( await loadRemote(obj.common.javascriptRules!.name + '/' + obj.common.javascriptRules!.name) as any ).default; diff --git a/src-editor/vite.config.ts b/src-editor/vite.config.ts index bd8ced84..7d0762f5 100644 --- a/src-editor/vite.config.ts +++ b/src-editor/vite.config.ts @@ -23,7 +23,10 @@ export default defineConfig({ federation( { name: 'iobroker_javascript', shared: makeShared([ - 'react', 'react-dom', '@mui/material', '@mui/styles', '@mui/icons-material', 'prop-types', '@iobroker/adapter-react-v5', 'react-ace', + 'react', 'react-dom', '@mui/material', + //'@mui/styles', + //'@mui/icons-material', + 'prop-types', '@iobroker/adapter-react-v5', 'react-ace', ]), exposes: {}, remotes: {},