Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript plugin support #12

Open
einarq opened this issue Jan 18, 2023 · 3 comments
Open

TypeScript plugin support #12

einarq opened this issue Jan 18, 2023 · 3 comments

Comments

@einarq
Copy link

einarq commented Jan 18, 2023

Does the importRemote util work with the MF typescript plugin?

Meaning, if you import a React component like this, does it also preserve any types?

importRemote({ url: "http://localhost:3001", scope: 'Foo', module: 'Bar' }).then(({/* list of Bar exports */}) => {
@einarq
Copy link
Author

einarq commented Jan 18, 2023

Btw, I came here via this issue:
module-federation/module-federation-examples#681 (comment)

We are trying to find the best way to actually postpone loading the remoteEntry, and other modules that it drags with it, until any module from this remote is actually needed.
Currently MF has the unfortunate side-effect of pre-loading too much stuff it seems.

@einarq
Copy link
Author

einarq commented Jan 18, 2023

Also have this issue over on the external-remotes-plugin:
module-federation/external-remotes-plugin#6

That plugin is deprecated, right? Is "importRemote" the current recommendation?
Or is the recommendation still to use the "promise new Promise" approach mentioned in the docs?

@alex-vukov
Copy link
Contributor

alex-vukov commented Mar 16, 2023

Hi @einarq! I am just seeing this issue. Sorry for the delay. importRemote does not preserve the types from the module it imports dynamically, however it can be passed a generic type which then will be assigned to the resolved object. So you can use it like this for example importRemote<{title: string; children?:JSX.Element;}>({ url: "http://localhost:3001", scope: 'Foo', module: 'Bar' })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants