Skip to content

Commit

Permalink
module federation
Browse files Browse the repository at this point in the history
  • Loading branch information
DileSoft committed Dec 16, 2024
1 parent 31dabe2 commit 058271b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -211,17 +211,16 @@ export const ContextWrapper = ({ children, socket }: { socket: AdminConnection;
}

try {
init({
name: obj.common.javascriptRules!.name,
remotes: [
registerRemotes(
[
{
name: obj.common.javascriptRules!.name,
entry: url,
type: 'module'
}
],
// 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;
Expand Down
5 changes: 4 additions & 1 deletion src-editor/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {},
Expand Down

0 comments on commit 058271b

Please sign in to comment.