-
-
Notifications
You must be signed in to change notification settings - Fork 266
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
Add option to supply a base path when resolving types from relative remote urls #2963
Comments
looks nice , since you have known how to fix it , can you help to open a pr ? |
You bet. #3042 |
Hey @ScriptedAlchemy would you like me to re-open the PR? Have you had an opportunity to look at the example I shared? |
Yeah let's re open the pr |
@ScriptedAlchemy It doesn't look like I can re-open. You might be able to do that. I can create a new PR -- I do need to rebase the changes and update documentation in zh too. So I can do that and create a new PR tomorrow if you'd like. |
Reopened |
Is there any workaround for this at the moment while we wait for the merge |
I've been working basically without the DTS feature for now (similar to what MF1 had), where I will either have stubbed .d.ts files, or I'll pull the remote also as an npm dependency just to use the types. If you want to use the DTS feature there are a few options that might work for you:
// rsbuild.config.ts
const remoteBase = process.env.REMOTE_BASE ?? '';
export default defineConfig({
plugins: [
pluginModuleFederation({
name: 'host',
remotes: {
'buttons': `buttons@${remoteBase}/module/buttons/mf-manifest.json`
}
}),
],
}); |
Clear and concise description of the problem
I would like a way to specify the absolute url of remotes for type generation, but use a relative path to resolve the module at runtime. Relative remote paths allow for simpler configuration for domain agnostic deployments across dev and prod environments. Unfortunately without specifying the absolute URL the dts-plugin does not know where to grab the types.
For example a host may have the following remote configuration:
MyRemote: 'MyRemote@/relative-path/mf-manifest.json'
Loading the host app up under
http://localhost:3000
would correctly resolve the relative path ashttp://localhost:3000/relative-path/mf-manifest.json
. However the dts-plugin will try to load the types directly from the relative path and fails with this warning found intypesGenerate.log
Suggested solution
One solution could be to add a new configuration option to the
DtsHostOptions
in the sdk package:We would use this option as the base path whenever we are supplied a relative remote in the dts-plugin package:
Alternative
An alternative could be to leverage the host's
publicPath
and or thegetPublicPath
function. I'm not sure this would be the correct application of those features.Additional context
This is a similar use-case outlined by @adamdharrington and partially solved in #2406
I also know I did this backwards, but I have a WIP implementation available for more context.
Validations
The text was updated successfully, but these errors were encountered: