-
Notifications
You must be signed in to change notification settings - Fork 27
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
example: Hotreloading Type Declerations #113
base: main
Are you sure you want to change the base?
Conversation
@@ -6,7 +7,7 @@ import './index.css'; | |||
import viteLogo from '/vite.svg'; | |||
|
|||
const RemoteButton = lazy(() => import('remote/Button')); | |||
const WebpackButton = lazy(() => import('webpack/Image')); | |||
const WebpackButton = lazy(() => loadRemote('webpack/Image')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://module-federation.io/static/image/hot-types-reload.c4031555.gif autocomplete missing
import logo from './assets/webpack-logo.png'; | ||
|
||
const WebpackImage = () => { | ||
const WebpackImage = ({ foo }: { foo: number }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing types on the component in host
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know its jsx but it can still use and should have the @mf-types/ folder extracted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The foo: number is added for example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 👍 it helps a lot
@@ -69,6 +69,14 @@ module.exports = { | |||
name: 'webpack', | |||
filename: 'remoteEntry.js', | |||
remotes: {}, | |||
dts: { | |||
generateTypes: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with this you can see it creates a dist folder with the types that should be synced to the folder in host
The
so I think we need to do the same |
dts: { | ||
consumeTypes: true, | ||
}, | ||
dev: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://module-federation.io/configure/dev.html some relevent options for types hot reloading too
We can't use |
Yes, but the DTS manager itself is agnostic and could be implemented in other bundlers. |
My colleague is on leave this week, but he understands the DTS system best. It's quite intricate, but there's a DTS manager that should create a separate server for handling type requests and builds. We can also register dynamic remote types from the browser by sending the data back to the DTS server, which then generates the discovered types. |
I'm creating a "generic compiler" that is implementing all the methods needed 😉 |
Perfect. You can send a pr back to core if additional changes or packages need to be created for dts to support other tools |
Repo example for #112
Docs here https://module-federation.io/configure/dts.html
Expected a the host to generate a
@mf-types/
as described in here https://module-federation.io/guide/basic/type-prompt.html