Error while sharing the state from mono-repo shell app

28 views Asked by At

I am trying to share state created with zustand from a mono-repo shell application to an external app outside the mono-repo which is also created using monorepo.


type Store = {
  count: number;
  increment: () => void;
};

const sharedStore = create<Store>((set) => ({
  count: 0,
  increment: () => set((state) => ({ count: state.count + 1 })),
}));

export default sharedStore;

exported from index file like

export { default } from './lib/lib-store';

when shared normally using

in Recipient:

remotes: [['host', 'http://localhost:4200/remoteEntry.js']],

in host:

exposes: { './sharedStore': '../shared/src/lib/lib-store', },

and then use host/sharedState

this works, but if I am trying to get this dynamically I m getting below error. TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.invokeGetter (:3:28)

to dynamically load I used below code

  loadRemoteModule({
      type: 'module',
      remoteEntry: 'http://localhost:4200/remoteEntry.js',
      exposedModule: './sharedStore',
    }).then((m) => {
      console.log(`Success:: Loaded external module:`, m);
      onSuccess(m);
    });

Module is loaded.

tsconfig in both projects has

"alwaysStrict": false,

What could be the reason?

0

There are 0 answers