core icon indicating copy to clipboard operation
core copied to clipboard

Align package configuration api

Open ulrichgreen opened this issue 1 year ago • 2 comments

Clear and concise description of the problem

This is a minor one :) ... My OCD goes a little bit off when I have to do this when configuring all your wonderful packages (typescript setup):

import { ModuleFederationPlugin } from '@module-federation/enhanced';
import { FederatedTypesPlugin } from '@module-federation/typescript';
import { NativeFederationTestsRemote } from '@module-federation/native-federation-tests';

const moduleFederationConfig = {// config here}

new ModuleFederationPlugin(moduleFederationConfig),
new FederatedTypesPlugin({ federationConfig: moduleFederationConfig }),
NativeFederationTestsRemote.webpack({ moduleFederationConfig }),

Suggested solution

I would love to have the interfaces aligned and be able to do:

import { ModuleFederationPlugin } from '@module-federation/enhanced';
import { FederatedTypesPlugin } from '@module-federation/typescript';
import { NativeFederationTestsRemote } from '@module-federation/native-federation-tests/webpack';

const moduleFederationConfig = {// config here}

new ModuleFederationPlugin({ moduleFederationConfig }),
new FederatedTypesPlugin({ moduleFederationConfig }),
new NativeFederationTestsRemote({ moduleFederationConfig }),

This will, in my eyes, make it a bit more streamlined to use for us consumers.

And just to spell it out :) some plugins expect a key like "federationConfig", while others expect "moduleFederationConfig". Some requires instantiation (new Plugin() vs Plugin()). The exact naming is not so important, as log as its aligned.

Alternative

No response

Additional context

No response

Validations

  • [X] Read the Contributing Guidelines.
  • [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

ulrichgreen avatar Apr 30 '24 06:04 ulrichgreen

Federated Types can be replaced with just module federation enhanced, since it comes with built in type system already.

ScriptedAlchemy avatar May 01 '24 04:05 ScriptedAlchemy

If you want to avoid to use NativeFederationTests.webpack, you should import the native-federation-tests/webpack module.

You'll still be unable to use "new" keyword due to the structure of the plugin.

ilteoood avatar May 01 '24 06:05 ilteoood

Closing, as my OCD is satisfied with the built in type system :)

ulrichgreen avatar May 16 '24 12:05 ulrichgreen