-
-
Notifications
You must be signed in to change notification settings - Fork 349
Description
Clear and concise description of the problem
Hi @ilteoood 👋
It would be great to have more flexibility in @module-federation/native-federation-typescript
plugin
Here are my comments:
NativeFederationTypeScriptRemote
typesFolder: './types/@my-mf-types'
(nested) generates empty./dist/types
folder- When using with
@module-federation/enhanced/webpack
(or@module-federation/manifest
), this plugin doesn't changemf-manifest.json
file. Example:
// webpack.config.js
const { ModuleFederationPlugin } = require('@module-federation/enhanced/webpack')
const { NativeFederationTypeScriptRemote } = require('@module-federation/native-federation-typescript/webpack')
plugins: [
new ModuleFederationPlugin({
...federationConfig,
dts: false, // disable to generate with NativeFederationTypeScriptRemote
}),
NativeFederationTypeScriptRemote({
moduleFederationConfig: federationConfig,
typesFolder: './types/@my-mf-types',
}),
],
// generated mf-manifest.json
// ...
"metaData": {
// ...
"types": {
"path": "",
"name": "",
"zip": "",
"api": ""
},
},
// ...
NativeFederationTypeScriptHost
-
typesFolder
is also used as link to remote (example:https://.../${typesFolder}.zip
). So I can't change this parameter at all
(source: https://github.com/module-federation/core/blob/main/packages/native-federation-typescript/src/configurations/hostPlugin.ts#L22) -
deleteTypesFolder
deletes@mf-types/@example/app
before@mf-types.zip
is successfully downloaded. If server is down - plugin removes your types
(source: https://github.com/module-federation/core/blob/main/packages/native-federation-typescript/src/lib/archiveHandler.ts#L74) -
HostPlugin doesn't generates
./@mf-types/index.d.ts
withloadRemote
typings (unlike@module-federation/dts-plugin
) -
You can't set
@mf-types.zip
path for every remote separately
Suggested solution
NativeFederationTypeScriptRemote
- Allow nested
typesFolder
- Implement integration with
@module-federation/manifest
(maybe using additional props or plugins)
NativeFederationTypeScriptHost
-
typesFolder
should be used only as download destination directory path -
deleteTypesFolder
shouldn't delete types on error (if server is not available) -
Implement
./@mf-types/index.d.ts
generation forloadRemote
function, just like in@module-federation/dts-plugin
(source: https://github.com/module-federation/core/blob/main/packages/dts-plugin/src/core/lib/DTSManager.ts#L290)
(example: https://github.com/module-federation/module-federation-examples/blob/11dcb0d6d28c26733da82e3805d7c2e3c9f4c65d/rspack_hmr/host/%40mf-types/index.d.ts)
Allow additional parameters in remotes
section. Example:
// plugin config
remotes: [
{
entry: 'https://.../remoteEntry.js',
typesZip: '@my-mf-types.zip' // or 'https://.../@my-mf-types.zip'
// also add .zip automatically, if value has no `.zip` substring
}
]
OR/AND
Take @mf-types.zip
path from mf-manifest.json
(types
section`). Example:
// plugin config
remotes: [
{
entry: 'https://.../mf-manifest.json',
}
]
// mf-manifest.json
metaData: {
types: {
zip: './@my-mf-types.zip'
}
}
Alternative
No response
Additional context
No response
Validations
- Read the Contributing Guidelines.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.